For example:
%typemap(in) int MYINT (int $1_temp) { ... }
$1_temp is typically expanded to arg1_temp, arg2_temp etc depending on
which argument the typemap is applied to.
PEP-394 recommends specifying python2 or python3 in shebangs unless the
script is known to only run in an activated virtual environment.
PEP-394 also says distributors may not provide the python command.
Newer versions of Ubuntu, at least, no longer provide python unless the
python-is-python3 package is explicitly installed.
Removed some shebangs from testcases (the test-suite does not need them).
Update the v8 support to work with recent v8 releases.
Fix bitrot in the testsuite and examples so they pass for v8.
Adjust configure probes so we can successfully probe for v8 without
assistance on Debian and Ubuntu (and probably other platforms; those
are just the two I've tested, and both use multiarch library
directories which weren't being allowed for).
Closes#3028
See #2537
This is no longer needed since we dropped support for the ancient
V8 versions which didn't provide version macros, but I missed
removing it in my previous cleanup in
48eba82ac8.
Assigning to a property in JS always works, as it just creates a new
property if there is no existing one, and so can't be used for testing
for its existence.
Set the property value in C code and try accessing it from JS instead.
Also check that not only the property with the expected name exists, but
also that the property with the renamed name does not.
See #2943.
At least when building in a separate build directory, building this test
second time fails due to a syntax error in the makefile created by
node-gyp which happens because it doesn't handle dependencies with
spaces in them correctly.
Fix this by simply avoiding using such dependencies when using node-gyp,
this is not a big loss as the goal here is to test SWIG preprocessor and
not JS backend itself, and the preprocessor is still tested with the
other languages.
Closes#2930.
Use $(ECHO_PROGRESS) instead of the hard-coded "echo" to allow setting
ECHO_PROGRESS=: on make command line to suppress the (many hundreds of)
messages given when running every unit test.
This makes it much easier to see any warnings given during the test
suite execution.
Null pointers returned from functions also using output parameters or C
strings typemaps were lost because the generated code didn't distinguish
between Py_None corresponding to them and Py_None indicating the return
value of a "void" function.
This doesn't seem to be easy to solve properly because the function
return type and output parameters typemaps are independent and there is
no way to customize the behaviour of the latter depending on the former.
So we do it using a hack involving a global variable which is always 0
and is passed to SWIG_Python_AppendOutput() from non-void functions, but
is shadowed by a local variable with the same name set to 1 in the void
ones. This allows us to only discard Py_None if it corresponds to a void
function return value.
This is obviously ugly, but requires only minimal changes, doesn't
impose much extra run-time overhead and is MT-safe (unlike any solution
involving changing global variables).
Also add a unit test checking for this for Python and for JS, where the
same function already worked correctly (unlike in some other languages,
including at least Ruby and PHP).
Closes#2905.
* char_binary_java_fix-tidyup:
Move SWIGStringWithLengthHelper to csharphead.swg
cdata whitespace/cosmetic fixups
cdata doc updates
Rename `typemaps/cdata_struct.swg` to `typemaps/cdata_begin.swg`. And `typemaps/cdata.swg` to `typemaps/cdata.swg`. Move `cdata_apply.swg` content to `typemaps/cdata.swg`.
Group the C# marshalling of STRING-LENGTH typemap into C# class named SWIGStringWithLengthHelper.
Leave Length & string reverse order typemap in typemaps/strings.swg
Support old C# as "LPUTF8Str" was add in 2017.
Improve documentation. Follow @wsfulton reviews.
Use a dummy for MzScheme and untested OCaml cdate. To prevent compilation error.
Further fixing follow reviews.
Reorganise raw data typemap, so typemaps folder contain only common part. Improve document.
Inline SWIG_string_to_utf8_bytes SWIG_utf8_bytes_to_string code
Fixes of STRING/BYTES LENGTH typemaps.
Conflicts:
CHANGES.current
Java's nested iterator class in std::map, std::set, std::unordered_map,
std::unordered_set needs to be public instead of protected for
access to work when moving STL types into different Java packages.
For example:
%nspace Space::OuterClass80;
namespace Space {
struct OuterClass80 {
struct InnerClass80 {
struct BottomClass80 {};
};
enum InnerEnum80 { ie80a, ie80b };
};
}
Previously the following were additionally required for some languages:
%nspace Space::OuterClass80::InnerClass80;
%nspace Space::OuterClass80::InnerClass80::Bottom80;
Now the appropriate nspace setting is taken from the outer class.
A new warning has also been introduced to check and correct conflicting
nspace usage, for example if the following is additionally added:
%nspacemove(AnotherSpace) Space::OuterClass80::InnerClass80;
The following warning appears as an inner class can't be moved outside
of the outer class:
Warning 406: Ignoring nspace setting (AnotherSpace) for 'Space::OuterClass80::InnerClass80',
Warning 406: as it conflicts with the nspace setting (Space) for outer class 'Space::OuterClass80'.
This really helps with %nspacemove as now one can simply move an outer
class to another namespace, like this:
%nspacemove(AnotherSpace) Space::OuterClass80;
and all the nested classes will automatically also be moved
into the appropriate namespace.
%nspacemove moves a class or enum into a different target language 'namespace'.
This builds on top of %nspace and so is currently only implemented in
C#, D, Java, Javascript and Lua.
Javascript also supports %nspace for functions and variables in a
namespace with a non-standard implementation; %nspacemove is not
fully working yet for Javascript.
Issue #2782
Fixes...
~/swig/github/swig/Examples/test-suite/javascript (master *>)$ make -s cpp17_nested_namespaces.cpptest ENGINE=jsc
checking javascript (jsc) testcase cpp17_nested_namespaces (with run test)
./cpp17_nested_namespaces_runme.js:6:TypeError: function is not a constructor (evaluating 'new cpp17_nested_namespaces.createA1Struct()')
instead of copy constructor when passing movable types by value.
Additional enhancement when passing movable types to constructors.
Enhancement to e777b054d5.
instead of copy constructor when passing movable types. This was
previously implemented only for parameters passed to a global function
or static member function and is now extended to member methods.
Enhancement to e777b054d5.
Fix Java STRING LENGTH typemap.
Use string type in static typed languages (Java, C#, D and Go).
Add BYTES LENGTH typemap and apply it for binary data.
Use byte type in static typed languages.
Add li_cdata_cpp, li_cdata and char_binary
tests for most of languages(apart from R and experimental).
Fix the director_binary_string test and add it to C#, D, Go,
Perl, PHP, Python, Ruby and octave.
Update documents.
Signed-off-by: Erez Geva <ErezGeva2@gmail.com>
In $typemap(), the $n special variables are replaced by the appropriate
value for the type associated with the typemap calling $typemap().
The (undocumented) special variable overrides now also support
controlling what the $n special variables are replaced with from the
calling typemap, for example:
%typemap(in) std::pair<std::string, int> {
int& input_value_second = $1.second;
$typemap(in, int, 1=input_value_second);
...
}
replaces $1 in the int typemap with input_value_second instead of
whatever is the default for the target language (a variable that holds
the int value after marshalling from the target language).
This additional functionality might make it possible to replace the C++
templates used in the UTL with a much simpler system of typemaps utilising
$typemap(). See follow on commit to typemaps.c.