Commit Graph

270 Commits

Author SHA1 Message Date
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
Sergio Garcia Murillo 56e7455af9 Return uint64_t as double if is bigger than uint32_t 2021-11-29 16:08:03 +01:00
William S Fulton ada739b4a8 Fix mismatched new char[] and free() - Javascript
Javascript - v8 and node only.
When wrapping C code char arrays.
Now calloc is now used instead of new char[] in SWIG_AsCharPtrAndSize.
Fixes gcc-11 warning -Wmismatched-new-delete in arrays and
memberin_extend testcases.
2021-11-12 19:00:20 +00:00
Hirokazu MORIKAWA 3fe47b4b46 [javascript][v8] SWIG_V8_VERSION generation method corrected.
"SWIG_V8_VERSION" generation method was incorrectly fixed.

Signed-off-by: Hirokazu MORIKAWA <morikw2@gmail.com>
2021-05-01 09:25:03 +09:00
William S Fulton 3f391478c4 Merge branch 'v8-context-aware-race-free-preparation'
* v8-context-aware-race-free-preparation:
  Lib/javascript/v8: use ::Cast instead of To* when possible.
  Lib/javascript/v8/javascriptrun.swg: clean up pre-processor conditions.
  Lib/javascript/jsc/javascriptinit.swg: shortcut JSGlobalContextRef casts.
  Examples/test-suite/grouping.i: resolve compiler warning.
2021-03-11 22:48:38 +00:00
William S Fulton 6aef217438 Add Javascript (JSC) support for type conversion
Fix types_directive testcase to ensure the %types code is actually
called and not just cast from one type to the other.
2021-03-11 20:18:58 +00:00
William S Fulton 04b46cc8a3 Javascript type conversion support
Add testcase for previous commit.
Add missing assert for future type conversions support that will use
the heap instead of pointer casts (for smart pointer type conversions).

Closes #1963
2021-03-11 20:10:13 +00:00
Andy Polyakov 2870e750f0 Lib/javascript/v8: use ::Cast instead of To* when possible.
If type is checked with Is*, it's safe to use corresponding ::Cast,
which is more optimal.
2021-03-10 14:51:08 +01:00
Andy Polyakov b56814ce08 Lib/javascript/v8/javascriptrun.swg: clean up pre-processor conditions.
Harmonize javascriptcode.swg javascripthelpers.swg and clarify
documentation.
2021-03-10 14:51:08 +01:00
Andy Polyakov 0c10c0596f Lib/javascript/jsc/javascriptinit.swg: shortcut JSGlobalContextRef casts. 2021-03-10 14:48:18 +01:00
Sergio Garcia Murillo fee5e239ec Use SWIG_TypeCast in SWIG_V8_ConvertInstancePtr if types don't match (#3)
Use SWIG_TypeCast in SWIG_V8_ConvertInstancePtr if types don't match
2021-03-10 08:34:45 +00:00
William S Fulton 513ea736d3 Merge branch 'array_fix'
* array_fix:
  add javascript_arays.i fix to changes file
  Convert javascript_arrays.i example into testcase
  Update .gitignore for java doxygen output
  Javascript code formatting corrections
  Fix Javascript arrays for modern node versions
  Fix for new SWIGV8_ARRAY_NEW definition
  Proper array typemaps in Javascript
2021-03-06 11:08:58 +00:00
William S Fulton db175f76c1
Merge pull request #1957 from dot-asm/v8-context-aware
Lib/javascript/v8: use context-aware initialization.
2021-03-05 22:28:42 +00:00
Sergio Garcia Murillo 6aeee8effc
Use SWIG_TypeCast in SWIG_V8_ConvertInstancePtr if types don't match (#3)
Use SWIG_TypeCast in SWIG_V8_ConvertInstancePtr if types don't match
2021-03-05 15:08:17 +01:00
William S Fulton b6aa39b82a Javascript code formatting corrections 2021-03-03 22:22:47 +00:00
William S Fulton c4d003e442 Fix Javascript arrays for modern node versions 2021-03-03 22:19:29 +00:00
William S Fulton 53bdc3964d Fix for new SWIGV8_ARRAY_NEW definition 2021-03-03 22:19:22 +00:00
William S Fulton 1a4dc82931
Merge branch 'master' into array_fix 2021-03-03 21:54:30 +00:00
William S Fulton d38c8d512f Merge branch 'vaughamhong-master'
* vaughamhong-master:
  fixed build error - ISO C90 forbids mixed declarations and code for jsc
  touch to kickoff another build - from accidental close pull request
  Implemented SetModule / GetModule for JSC to allow type sharing across modules - with fix for passing NULL to non-pointer argument
  Implemented SetModule / GetModule for JSC to allow type sharing across modules
2021-03-03 21:35:34 +00:00