Commit graph

17,115 commits

Author SHA1 Message Date
Karl Wette
b51bc39cf7 Add check-maintainer-clean target: fails if files are missed by maintainer-clean 2014-05-29 02:29:27 +02:00
Karl Wette
3fe1eb7056 Set SRCDIR when calling test-suite clean targets, in case it's needed 2014-05-29 02:29:27 +02:00
Karl Wette
cc0738bbda Fully clean Python examples and test-suite 2014-05-29 02:29:27 +02:00
Karl Wette
7f48b2774b Fully clean PHP test-suite 2014-05-29 02:29:27 +02:00
Karl Wette
fca95febde Fully clean Javascript test-suite with jsc and v8 2014-05-29 02:29:27 +02:00
Karl Wette
74e17fdbf6 Fix Javascript examples so that "make clean" works properly with node
- Need to copy example.cxx to build directory so that build products
  end up in the right place; use a gyp command expansion to do so
2014-05-29 02:29:27 +02:00
Karl Wette
32212d5cc0 Fully clean Go test-suite 2014-05-29 02:24:33 +02:00
Karl Wette
46ce4d3ba9 Distclean Tools/javascript 2014-05-29 02:24:33 +02:00
Karl Wette
cc1ff55be4 CCache: always generate docs in source directory 2014-05-29 02:24:33 +02:00
William S Fulton
78719759d5 Test-suite makefile fixes for Windows
Remove $(realpath ) which is no good for Windows executables running
under Cygwin's make
2014-05-28 23:44:55 +01:00
William S Fulton
68347cb723 Bump version to 3.0.2 2014-05-28 18:51:46 +01:00
Olly Betts
703862dc3a Fix unused variable warning in Lua bindings 2014-05-28 23:04:06 +12:00
Oliver Buchtala
f19592acf4 Merge branch 'master' of github.com:swig/swig 2014-05-28 04:27:54 +02:00
Oliver Buchtala
686d98672d Javascript: fixed a missing link in documentation. 2014-05-28 04:27:23 +02:00
William S Fulton
18c9eca182 Add Javascript to announcements 2014-05-27 23:39:51 +01:00
William S Fulton
85413bc84d Add 3.0.1 release date 2014-05-27 23:39:51 +01:00
William S Fulton
eeb1133606 Javascript html links and typo fixes 2014-05-27 23:39:46 +01:00
William S Fulton
f03bff152c Python 3 byte string output: use errors="surrogateescape" change note 2014-05-27 23:31:31 +01:00
William S Fulton
b531956467 Warning fixes compiling with Visual Studio 2014-05-27 21:55:17 +01:00
Oliver Buchtala
c342bc1b28 Javascript: added a link to the v8 web-site to the documentation. 2014-05-27 21:37:18 +02:00
Oliver Buchtala
a22f97eb33 Javascript: updated documentation about known issues.
[skip ci]
2014-05-27 10:44:13 +02:00
Oliver Buchtala
5d307b2cbf JavascriptCore: updated documentation about how to register an initialized module. 2014-05-27 10:41:39 +02:00
Oliver Buchtala
1df7ca77a0 JavascriptCore: added documentation about how to extract details from JSC errors.
This code is necessary for embedding applications to present details about JS exceptions.
2014-05-27 10:40:16 +02: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
Oliver Buchtala
01f8253b19 Javascript: added a section about known issues. 2014-05-26 21:38:00 +02:00
William S Fulton
55639cfff0 Merge branch 'hfalcic-master' - Python unicode surrogate escape strings
* hfalcic-master:
  unicode_strings test: manually check values instead of using assert
  unicode_strings_runme.py: fix version check
  unicode_strings test: check return values
  Python unicode_strings test case: restrict to Python > 3.0
  Python 3 'surrogateescape' docs: fix div class for Python code
2014-05-25 12:04:36 +01:00
William S Fulton
597c671e86 More diagnostics for csharp_exceptions testcase for diagnosing erratic failures 2014-05-25 12:00:42 +01:00
William S Fulton
4ab2eb96cd R examples building out-of-source
They still don't run though
2014-05-25 00:29:32 +01:00
William S Fulton
575ac1c170 Add 3.0.1 release notes summary 2014-05-25 00:03:19 +01:00
Harvey Falcic
91e93838fc unicode_strings test: manually check values instead of using assert 2014-05-24 18:00:04 -04:00
Harvey Falcic
ab527b0e4b unicode_strings_runme.py: fix version check
Python 3.0.1 shouldn't pass.
2014-05-24 17:57:16 -04:00
Harvey Falcic
2533d0210f unicode_strings test: check return values 2014-05-24 16:50:33 -04:00
Harvey Falcic
5c5dfc106f Python unicode_strings test case: restrict to Python > 3.0
Also adjust the test method names and content to match the docs.
2014-05-24 15:39:53 -04:00
Karl Wette
3e978fce9f Record files left over after maintainer-clean in Travis build 2014-05-24 20:25:56 +02:00
Karl Wette
bdc63e5a9f Remove example Makefiles when running distclean-examples in out-of-src build 2014-05-24 20:12:35 +02:00
Harvey Falcic
20ddfb7fcd Python 3 'surrogateescape' docs: fix div class for Python code 2014-05-24 13:30:03 -04:00
William S Fulton
d1f95ab6fd Merge pull request #165 from hfalcic/master
Python 3 byte string output: use errors="surrogateescape"
2014-05-24 17:54:55 +01:00
William S Fulton
8350288a6b Merge branch 'stricter-examples-compilation'
* stricter-examples-compilation:
  Travis testing - examples use stricter CFLAGS and CXXFLAGS
  Warning fixes in test-suite
  Refactor Lua class base search to make ISO c/c++ compliant
  Javascript warnings for c++98 - remove vla
  Fix compiler warnings in generated code when using -std=c++98 -std=gnu89 -pedantic -Wreturn-type
  Fix compiler warnings in examples when using -std=c++98 -std=gnu89 -pedantic -Wreturn-type
  Correct CFLAGS CXXFLAGS for Javascript and guile examples
2014-05-24 14:14:48 +01:00
William S Fulton
5990872cf7 Travis testing - examples use stricter CFLAGS and CXXFLAGS 2014-05-24 14:13:25 +01:00
William S Fulton
ab86f8a8f5 Warning fixes in test-suite 2014-05-24 14:13:24 +01:00
William S Fulton
10cbd2781f Refactor Lua class base search to make ISO c/c++ compliant 2014-05-24 14:13:24 +01: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
William S Fulton
f39ed94419 Fix compiler warnings in examples when using -std=c++98 -std=gnu89 -pedantic -Wreturn-type 2014-05-24 13:13:32 +01:00
William S Fulton
879296f71b Correct CFLAGS CXXFLAGS for Javascript and guile examples 2014-05-24 13:13:32 +01:00
Olly Betts
1a0b8abec7 Fix comment typo 2014-05-24 11:11:51 +12:00
Olly Betts
8d3902a666 Work towards C90 compatibility for Lua 2014-05-24 11:10:57 +12:00