Commit graph

184 commits

Author SHA1 Message Date
William S Fulton
6d27ead9c0 Add STL container copy constructors where missing
Also provide consistent copy constructor declarations.
2019-02-14 18:53:05 +00:00
William S Fulton
e26f6bb4e2 Add missing typedefs to std::vector + typedef corrections
Tests for std::vector of pointers added which check
 std::vector<T*>::const_reference and std::vector<T*>::reference
usage which gave compilation errors in Python and Perl which had
specialized these vectors incorrectly.
2019-02-13 22:46:28 +00:00
William S Fulton
a47c2553f5 Add missing typedefs to std::pair 2019-02-13 22:46:28 +00:00
William S Fulton
9dd33e6367 Add missing typedefs to std::map 2019-02-13 22:46:27 +00:00
William S Fulton
6d0c495fd0 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.
2019-02-13 22:45:47 +00:00
William S Fulton
ec8d978995 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.
2018-12-30 10:11:35 +00:00
William S Fulton
967776189e Add support for non-default compare template argument in std::map wrappers - Javascript 2018-10-09 22:42:49 +01:00
William S Fulton
4f7106cda2 Merge branch 'js-v8-52-tests'
* js-v8-52-tests:
  fixed nvm
  node tests: use provided version if present
  travis tests for different node versions
  fix travis tests
  Test NodeJS 4, 6, 8, and 10
  Remove warnings on Node 6.x aka V8 5.0 and 5.1
  Add Node 7.x aka V8 5.2+ support
2018-08-02 07:10:55 +01:00
luz.paz
60dfa31a67 Misc. typos
found via `codespell` and `grep`
2018-05-17 10:04:23 -04:00
William S Fulton
1f7689fa8f Javascript assert.h - move to header section
Fixes compile problem due to throw macro skullduggery in the director_throws testcase
2018-05-06 23:10:33 +01:00
Jacob Gillespie
6c78195d75
Merge branch 'master' into js-v8-52-tests 2018-05-01 21:26:59 -05:00
William S Fulton
7fbdd21b49 Javascript - Fix compilation error wrapping std::complex via std_complex.i
Closes #1187
2018-02-11 11:12:24 +00:00
William S Fulton
e01cfd70c7 Add missing declaration for std::complex
Fixes missing type information for std::complex in scripting languages.
Closes #732.

Update Javascript and Octave complextest, although they don't actually
get run as they don't work
2017-10-02 19:07:24 +01:00
Patrick Schneider
9ce8d7e7c9 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.
2017-04-13 19:39:44 +02:00
Patrick Schneider
f08d7a63a9 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
2017-04-13 15:02:53 +02:00
Olly Betts
b138f054e5 [Javascript] Fix SWIG_exception() macro (#792)
Fix SWIG_exception() macro to return from the current function.
Fixes #789, reported by Julien Dutriaux.
2016-09-17 17:29:42 +12:00
Olly Betts
b3bedc210c [Javascript] For v8 >= 4.3.0, use V8_MAJOR_VERSION.
Fixes https://github.com/swig/swig/issues/561.
2016-01-12 09:33:13 +13:00
Alec Cooper
4e2fc7d115 Don't use long long if it isn't available
Adds preprocessor checks to avoid defining functions that use long long if it isn't available
Effects the following languages: javascript, octave, perl, python, r, ruby, tcl
2016-01-06 16:52:37 -05:00
Olly Betts
d0dd63e437 "concret" -> "concrete" 2015-10-12 11:24:07 +13:00
William S Fulton
4e23595704 Unused method warning suppression for Javascript v8 2015-07-05 17:59:41 +01:00
William S Fulton
59ff3e6a3a C90 fixes for Javascript JSC 2015-02-11 23:32:45 +00:00
Oliver Buchtala
53d7fc8a16 Merge branch 'Richie765-master'
Conflicts:
	CHANGES.current
2014-09-30 18:46:25 +02:00
Richard
00457b6599 Making generated code more readable 2014-09-30 12:33:49 -03:00
Richard
0dfc1b090f Fix duplicate symbol linker errors for Javascript/v8 2014-09-09 10:08:30 -03:00
Richard
911fd761b0 Minor improvements 2014-08-28 19:46:52 -05:00
Richard
b8d7cc21b9 Use macros for V8 items 2014-08-28 19:46:52 -05:00
Richard
408390d146 Fixes for v8 3.18.3 (0x031803) 2014-08-28 19:46:51 -05:00
Richard
6fee208010 Fixes for v8 3.19.2 (0x031902) 2014-08-28 19:46:51 -05:00
Richard
eeb4b5497e Fixes for v8 3.24.17 (0x032417) 2014-08-28 19:46:51 -05:00
Richard
ee88602fde Use full name 2014-08-28 19:46:51 -05:00
Richard
dea3144726 Fixes for V8 3.22.24 (0x032224) Some errors left (??) 2014-08-28 19:46:51 -05:00
Richard
fee5748499 Fixes for 3.23.18 (0x032318) 2014-08-28 19:46:51 -05:00
Richard
d4920591d4 Fixes for v8 3.24.3 (0x032403) 2014-08-28 19:46:51 -05:00
Richard
c1222ebeec Partial fixes for 3.24.40 (0x032440) - incomplete 2014-08-28 19:46:50 -05:00
Richard
3c9e16ef85 Fixed some bugs from previous commit 2014-08-28 19:46:50 -05:00
Richard
e0c0670540 Partially fixed for 3.25.30 (0x032530) - unfinished 2014-08-28 19:46:50 -05:00
Richard
e98a659246 Fixes for v8 3.21.17 (0x032117) 2014-08-28 19:46:50 -05:00
Richard
3d63f9113b Fixes for v8 3.19.18 (0x031918) 2014-08-28 19:46:50 -05:00
Richard
013fb3d22d Fixes for v8 3.19.2 (0x031902) 2014-08-28 19:46:50 -05:00
Richard
8829230641 Fixes for v8 3.17.10 (0x031710) 2014-08-28 19:46:49 -05:00
Richard
47cbf621be Fixes for v8 3.15.11 (0x031511) 2014-08-28 19:46:49 -05:00
Mathieu Monney
ecdf692fc8 Fixed JSClassRef declaration not using the static one
The class descriptor is not assigned to the static variable but to a local one, which makes the global variable unused.
2014-07-02 11:27:27 +02:00
William S Fulton
22be94d207 Fix std::vector<bool> compile problems on OSX for Javascript 2014-05-31 19:58:42 +01:00
Eric Wing
1766e67a1a JavaScriptCore: Improved code that uses JSObjectMakeError instead of JSValueToObject to create the exception object.
JSObjectMakeError automatically populates the "message" field, and possibly other fields I don't know about. This seems to be the most robust way to create an exception object.

Thanks to Brian Barnes again for the tip on JSObjectMakeError.
2014-05-26 22:35:28 +02:00
Eric Wing
e7b20624cc JavaScriptCore: Reverted 2 of the JSValueMakeUndefined replacements because those functions are tied to JSObjectRef instead of JSValueRef. The C compiler will allow this, but C++ will reject the conversion.
It is unclear what the correct handling is for JavaScriptCore. (Nobody bothers to document this in JSCore.) Unlike our other problem where we incorrectly assume JSObjectRef when the functions want JSValueRef, this time Apple is demanding the JSObjectRef. Like our other problem, I assume it is unsafe to try to convert Undefined into a JSObjectRef.

So reverting to NULL seems like the safer bet for this specific case. Perhaps the other alternative is to return an exception object or an error object. But I would like to see JSCore document this before trying.
2014-05-26 22:35:27 +02:00
Eric Wing
f1c331f2c5 JavaScriptCore: Returning NULL for wrapper functions that expect JSValueRef may crash program.
According to this:
http://parmanoir.com/Taming_JavascriptCore_within_and_without_WebView
Returning NULL instead of an actual JSValueRef for a return value of a function could lead to crashes. I think I have seen related weirdness in the past when I failed to return a proper type to JSCore which resulted in very hard to understand behavior.

So this patch changes those return NULLs to return JSValueMakeUndefined().

I thought about JSObjectMakeError, but I don't fully understand the intent of the Error object and can't find any relevant real world examples of it being used. However, everybody seems to be using JSValueMakeUndefined().

This patch should be low impact since this is only triggered on an error condition.
2014-05-26 22:35:27 +02:00
Eric Wing
6f69555225 JavaScriptCore: Fixed exception object so sourceURL (file name), line (number), and message can be recovered.
The current implementation only returns an error string. But this is insufficient for debugging (what file and line number did it fail at?).

As documented here:
http://parmanoir.com/Taming_JavascriptCore_within_and_without_WebView
converting the JSValueRef of string to an JSObjectRef (via JSValueToObject) will trigger JSCore into filling the "sourceURL" and "line" properties into the object so they can be inspected by the caller.

Additionally, JavaScriptCore has a "message" property which contains the message string. JSCore doesn't seem to be filling this in for us automatically, unlike "sourceURL" and "line". So this patch also fills that property in too.

Thanks to Brian Barnes for the detailed information about "sourceURL", "line", and "message".

Below is an example (derived from Brian Barnes's information) on how you typically use/extract these exception details.

void script_exception_to_string(JSContextRef js_context,JSValueRef exception_value_ref,char* return_error_string, int return_error_string_max_length)
{
	JSObjectRef exception_object;
	JSValueRef value_ref;
	JSStringRef jsstring_property_name = NULL;
	JSValueRef temporary_exception = NULL;
	JSStringRef js_return_string = NULL;
	size_t bytes_needed;
	char* c_result_string = NULL;
	exception_object = JSValueToObject(js_context, exception_value_ref, NULL);
	// source and line numbers

	strcpy(return_error_string,"[");

	jsstring_property_name = JSStringCreateWithUTF8CString("sourceURL");
	value_ref = JSObjectGetProperty(js_context, exception_object, jsstring_property_name, &temporary_exception);
	JSStringRelease(jsstring_property_name);
	js_return_string = JSValueToStringCopy(js_context, value_ref, NULL);
	bytes_needed = JSStringGetMaximumUTF8CStringSize(js_return_string);
	c_result_string = (char*)calloc(bytes_needed, sizeof(char));
	JSStringGetUTF8CString(js_return_string, c_result_string, bytes_needed);
	SDL_Log("c_result_string: %s\n", c_result_string);
	JSStringRelease(js_return_string);
	strncat(return_error_string, c_result_string, return_error_string_max_length-1);
	free(c_result_string);

	strncat(return_error_string, ":", return_error_string_max_length-1);

	jsstring_property_name = JSStringCreateWithUTF8CString("line");
	value_ref = JSObjectGetProperty(js_context, exception_object, jsstring_property_name, &temporary_exception);
	JSStringRelease(jsstring_property_name);
	js_return_string = JSValueToStringCopy(js_context, value_ref, NULL);
	bytes_needed = JSStringGetMaximumUTF8CStringSize(js_return_string);
	c_result_string = (char*)calloc(bytes_needed, sizeof(char));
	JSStringGetUTF8CString(js_return_string, c_result_string, bytes_needed);
	SDL_Log("c_result_string: %s\n", c_result_string);
	JSStringRelease(js_return_string);
	strncat(return_error_string, c_result_string, return_error_string_max_length-1);
	//SDL_Log("c_result_string: %s\n", c_result_string);
	free(c_result_string);

	strncat(return_error_string, "]", return_error_string_max_length-1);

	/* get message */
	jsstring_property_name = JSStringCreateWithUTF8CString("message");
	value_ref = JSObjectGetProperty(js_context, exception_object, jsstring_property_name, &temporary_exception);
	JSStringRelease(jsstring_property_name);
	if(NULL == value_ref)
	{
		strncat(return_error_string, "Unknown Error", return_error_string_max_length-1);
	}
	else
	{
		js_return_string = JSValueToStringCopy(js_context, value_ref, NULL);
		bytes_needed = JSStringGetMaximumUTF8CStringSize(js_return_string);
		c_result_string = (char*)calloc(bytes_needed, sizeof(char));
		JSStringGetUTF8CString(js_return_string, c_result_string, bytes_needed);
		SDL_Log("c_result_string: %s\n", c_result_string);
		JSStringRelease(js_return_string);
		strncat(return_error_string, c_result_string, return_error_string_max_length-1);
		//SDL_Log("c_result_string: %s\n", c_result_string);
		free(c_result_string);
	}
}

To use:
if(js_exception)
{
	char return_error_string[256];
	script_exception_to_string(js_context, js_exception, return_error_string, 256);
	SDL_Log("Compile error is %s", return_error_string);
}
2014-05-26 22:35:27 +02:00
William S Fulton
c2368a40b2 Javascript warnings for c++98 - remove vla 2014-05-24 14:13:24 +01:00
William S Fulton
3191473523 Fix compiler warnings in generated code when using -std=c++98 -std=gnu89 -pedantic -Wreturn-type 2014-05-24 14:13:19 +01:00
Oliver Buchtala
61b7da1671 JavascriptCore: Bugfix for null-pointer support.
This solution must be considered as a preliminary workaround.
2014-05-19 16:04:22 +02:00