Commit Graph

288 Commits

Author SHA1 Message Date
Thanh Vu Le 935f9222a3 [Javascript] Use SetNativeDataProperty()
Use SetNativeDataProperty() instead of SetAccessor() which fixes
compatibility with recent v8 versions.

Closes #3185
Fixes #3138
2025-06-09 16:11:29 +12:00
William S Fulton 36ef36dcb0 Add <errno.h> fragment for errno usage 2024-11-22 19:07:10 +00:00
Olly Betts 7274c3f9b7 Make minimum supported v8 version 7.4
This is the oldest we are able to test in CI, and only then via it being
the version use by the oldest node.js we can test in CI.  We have no
direct testing with v8 in CI currently, and it seems hard to
v8_shell.cxx no longer building with more recent v8 versions.

See #2537
2024-09-19 08:25:44 +12:00
William S Fulton 9bf4842002 C++ reference errors when passing in a 'NULL' change of behaviour.
Most languages now use "NullReferenceError" in the error message
where they previously used "ValueError". Also exception changes:

Guile:    "swig-null-reference-error" instead of "swig-value-error"
MzScheme: "swig-null-reference-error" instead of "swig-value-error"
PHP:      zend_ce_type_error instead of zend_ce_value_error
Python:   Consistently raises TypeError instead of a mix of ValueError
          and TypeError.
Ruby:     Consistently raises NullReferenceError instead of a mix of
          ArgumentError and NullReferenceErrorError.

The consistent raising of a TypeError instead of ValueError for Python
ensures that incorrectly passing 'None' into a C++ reference argument
will correctly convert the error into a NotImplemented error for
the rich comparisons implementations per PEP 207. Fixes #2987

Note that the li_constraints checking implementation for the NONNULL
typemap for pointers also makes the same error change from
SWIG_ValueError to SWIG_NullReferenceError.

The D typemaps use SWIG_DNullReferenceException instead of
SWIG_DIllegalArgumentException, although this ultimately has no change
as the same D Exception is still thrown.
2024-09-14 13:03:36 +01:00
Olly Betts 494a782714 Fix some source comments 2024-07-19 09:28:33 +12:00
Vadim Zeitlin 474a936b15 Move javascriptkw.swg file to Lib/javascript directory
This file is JS-specific and should be in JS subdirectory, for
consistency with all the other languages.
2024-07-18 22:27:52 +02:00
Vadim Zeitlin 628e356f8b Avoid duplicating std::vector<> declaration for JavaScript
Use a helper macro abstracting the difference between the generic
version and the bool specialization of std::vector<> instead of
duplicating the entire class declaration.

No real changes, but this will help with future modifications by
allowing to make them only once instead of twice.

Don't pass separate REFERENCE to JS macro defining std::vector

Just use "CTYPE&" for both the generic case and bool specialization,
it is still wrong (as std::vector<bool>::reference is a proxy type
different from this one), but not worse than before and it's simpler to
have 2 arguments in SWIG_STD_VECTOR_INTERNAL() macro rather than 3.
2024-06-25 07:54:00 +01:00
William S Fulton ba9b0a35ab Merge branch 'char_binary_java_fix-tidyup'
* 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
2024-06-13 10:53:19 +01:00
William S Fulton 2d1944a407 Fix JavaScript _wrap_getCPtr on 64-bit Windows
error: cast from 'void*' to 'long int' loses precision

Closes #2869
2024-04-12 18:34:02 +01:00
William S Fulton 2f194c10a8 Remove some locator strings in generated code
For Javascript, MzScheme, Python, Ruby.
Removes the vast majority of the /*@SWIG:...*/ locator strings in the
generated wrappers for these 4 languages to help with reproducible builds.

Issue #202
2024-04-12 08:12:44 +01:00
William S Fulton 24a66e6125 Add const std::unique_ptr & input typemaps 2024-03-06 21:46:58 +00:00
William S Fulton 846b40793e Add non-const std::unique_ptr & input typemaps 2024-03-06 21:46:58 +00:00
William S Fulton 5712ce6464 std::unique_ptr return by reference typemaps added 2024-03-06 21:46:58 +00:00
William S Fulton 3f1e40d2f4 Add std::unique_ptr && output typemaps
Move semantics are not supported by default.
They behave as if a lvalue reference was returned.
2024-03-06 21:46:58 +00:00
William S Fulton e76952e355 Support NULL being passed into char* in typemaps
Missing functionality for Javascript, MzScheme, Octave.
Tested in follow on commit in cpp11_std_unique_ptr testcase.
2024-03-06 21:46:58 +00:00
William S Fulton ae22a97f1b Movable std::unique_ptr - add std::unique_ptr && typemaps
Closes #2650
2024-03-06 21:46:58 +00:00
Erez Geva affbd5893d Reorganise raw data typemap,
so typemaps folder contain only common part.
Improve document.

Signed-off-by: Erez Geva <ErezGeva2@gmail.com>
2024-02-29 11:58:05 +01:00
Olly Betts 3a437b2017 Remove deprecated map and vector specialisation macros
These have done nothing except emit a warning saying they are no
longer required for a long time.

One exception is guile and mzscheme still define non-trivial
specialize_std_map_on_* - it seems they were missed for some
reason, but the same improved machinery which meant these macros
are no longer required for other target languages should apply
to them too.
2023-12-03 09:55:35 +13:00
Olly Betts a8091575c1 Fix typos in comments and docs 2023-11-30 17:07:16 +13:00
Olly Betts 3ce0174a0c Fix random doubled spaces in code 2023-11-17 09:49:36 +13:00
Olly Betts 77d6365255 Remove reintroduced reference to BOTH
I removed BOTH in 779fa45601 - it looks
like this reference is from a change merged after that based on the code
before the removal.
2023-10-25 09:37:56 +13:00
William S Fulton 76fdf2c355 std::map wrappers and non-default constructible
Fix and test Guile, MzScheme, Java, Javascript
Octave is also failing.
2023-09-15 19:17:34 +01:00
Christophe Calmejane f7d9f5e931 Using #ifdef instead of #if to prevent warnings 2023-07-04 09:18:20 +02:00
Christophe Calmejane 2b583e9d19 Fix for #2625
Using c++17 insert_or_assign for std::map when available.
2023-07-04 09:18:20 +02:00
Momtchil Momtchev ceed54758a Javascript Node-API support added
Closes #2545
2023-06-28 07:24:51 +01:00
Olly Betts 779fa45601 Remove deprecated BOTH typemap rule
This has been a deprecated alias for INOUT since 2002 (SWIG 1.3.14).
2023-06-15 15:07:04 +12:00
Momtchil Momtchev fd3898367a bring in the `size_t` `cmalloc` in JS
The default `cmalloc` uses an `int` argument
2023-05-31 14:11:13 +02:00
Momtchil Momtchev 721a4808b8 remove hacks and implement default arguments 2023-05-31 13:22:35 +02:00
Olly Betts 0c40ac59f1 Merge branch 'v8-packed-obj' 2023-05-30 17:49:49 +12:00
Momtchil Momtchev b83fc1fda6 remove the check from free 2023-05-29 22:13:43 +02:00
Momtchil Momtchev 05fd4878fe reset the persistent in the weak callback 2023-05-29 22:12:32 +02:00
Momtchil Momtchev de3c2fea95 fix JSC too 2023-05-29 21:02:42 +02:00
Momtchil Momtchev 2ccf3c3050 fix member pointers 2023-05-29 20:17:31 +02:00
Momtchil Momtchev 92dfc5de2e first batch of tests 2023-05-29 12:39:51 +02:00
Olly Betts eaefa489c5 [js] argcargv.i: Allow empty array or empty string 2023-05-22 14:08:13 +12:00
Olly Betts fcdd63dba5 Remove redundant NULL checks before free()
See 7ec2f89fe2
2023-05-20 16:17:00 +12:00
Erez Geva bdc2190cde Add argc and argv multi-argument typemap to Java, Guile, JavaScript, Scilab and C#
Fixes #2552

Signed-off-by: Erez Geva <ErezGeva2@gmail.com>
2023-05-20 16:17:00 +12:00
Olly Betts 1f5ff2e6a5 Allow using snprintf() instead of sprintf() in wrappers
We aim to produce code that works with C90 or C++98 so we can't
assume snprintf() is available, but it almost always is (even
on systems from before it was standardised) so having a way to
use it is helpful.

Enable this automatically if the compiler claims conformance
with at least C90 or C++98 and check SWIG_HAVE_SNPRINTF to allow
turning on manually, but disable if SWIG_NO_SNPRINTF if defined.

The fallback is to call sprintf() without a buffer size check -
checking after the call is really shutting the stable door after
the horse has bolted, and most of our uses either have a fixed maximum
possible size or dynamically allocate a buffer that's large enough.

Fixes: #2502 (sprintf deprecation warnings on macos)
Fixes: #2548
2023-04-27 10:08:57 +12:00
William S Fulton bba072d95d Merge branch 'fix-cast'
* fix-cast:
  add tests for new casting behavior
  skip tests when value is out of range
  refactor integers JS testcase to avoid repeating code
  Return uint64_t as double if is bigger than uint32_t
  Use SWIG_TypeCast in SWIG_V8_ConvertInstancePtr if types don't match (#3)
2022-10-14 19:19:13 +01:00
William S Fulton d32943b2a9 Javascript v8 object to string exceptions improvement 2022-09-19 09:09:29 +01:00
William S Fulton 00190c484f Javascript, Octave, R - Improve exceptions for %catches
and exception specifications for native types.

Now the raised exception contains the string value as the exception
message instead of just the C/C++ type of the exception.

R exceptions were completely swallowed beforehand
2022-09-19 09:09:29 +01:00
William S Fulton e97181ebc0 Add missing typecheck typemaps for std::auto_ptr and std::unique_ptr
To fix overloading when using these types.
2022-09-17 10:23:51 +01:00
William S Fulton dad7c93ca0 Provide SWIGTYPE MOVE typemaps in swigmove.i
For implementing full move semantics when passing parameters by value.
Based on SWIGTYPE && and std::unique_ptr typemaps which implement move
semantics.

Added for all languages, but untested for: Go, Ocaml, R, Scilab (and
unlikely to be fully functional for same reasons as for std::unique_ptr
support).

Issue #999
2022-09-16 08:36:25 +01:00
William S Fulton fe17296eb4 Add Javascript support for std::unique_ptr and std::auto_ptr
Equivalent to Ruby/Python implementations.
2022-08-04 07:14:30 +01:00
William S Fulton 72f7b82935 Correct warning message for wchar_t * typemaps
Use separate warning for char * and wchar_t * typemaps
SWIGWARN_TYPEMAP_CHARLEAK_MSG and SWIGWARN_TYPEMAP_WCHARLEAK_MSG
2022-05-06 18:44:02 +01:00
Olly Betts 8dbcd710ff [Javascript] Fix handling of functions which take void*
Fixes #682
2022-03-07 14:17:52 +13:00
Olly Betts b127e11f1e Fix typos in docs and comments 2022-02-27 18:15:46 +13:00
Olly Betts 7c97bd5ab3 [js] Remove code to handle v8 < 5.0
We require at least node v6 which means v8 5.0, so code to handle
older v8 is no longer useful.
2021-12-02 14:04:25 +13:00
William S Fulton f17b6bda93 Merge branch 'fix_SWIG_V8_VERSION'
* fix_SWIG_V8_VERSION:
  [javascript][v8] SWIG_V8_VERSION generation method corrected.
2021-12-01 18:22:29 +00:00
Sergio Garcia Murillo 975a36d5a5
Merge branch 'fix-cast' into master 2021-11-29 16:12:38 +01:00