Commit graph

2,996 commits

Author SHA1 Message Date
Simon Marchetto
7289fa7e75 scilab: rename wrapper global variable fname to SwigFuncName 2014-09-11 12:14:11 +02:00
Simon Marchetto
4bb8c90101 Revert "scilab: remove useless SWIG_Scilab_SetOutput() second parameter"
This reverts commit 99c82bffa5.
2014-09-11 11:44:38 +02:00
Simon Marchetto
429af4052f Revert "scilab: fix compilation error (extra parenthesis)"
This reverts commit 7249cd6a97.
2014-09-11 11:44:15 +02:00
Simon Marchetto
c5cf834f3e Revert "scilab: fix compilation error (too many args in SWIG_Scilab_SetOutput)"
This reverts commit af822c640c.
2014-09-11 11:43:50 +02:00
Simon Marchetto
af822c640c scilab: fix compilation error (too many args in SWIG_Scilab_SetOutput) 2014-09-10 15:32:34 +02:00
Simon Marchetto
7249cd6a97 scilab: fix compilation error (extra parenthesis) 2014-09-10 15:26:14 +02:00
Simon Marchetto
99c82bffa5 scilab: remove useless SWIG_Scilab_SetOutput() second parameter 2014-09-09 15:05:12 +02:00
William S Fulton
1f6b71b47b Scilab parameter name changes
Remove _ prefix in parameter names
2014-09-04 20:14:35 +01:00
William S Fulton
ffbaf424ca Fix previous commit.
li_std_vector testcase was failing. This needs diagnosing.
2014-09-04 20:14:35 +01:00
William S Fulton
53aa3ec5fc Correct global variable name in Scilab wrappers 2014-09-03 20:07:51 +01:00
Simon Marchetto
29f45d91ad scilab: apply K&R coding style for typemaps 2014-08-12 17:31:47 +02:00
Simon Marchetto
460e737df1 scilab: use SWIG_Scilab_Raise() for exceptions 2014-08-08 16:30:00 +02:00
Simon Marchetto
caeaf7dc7e scilab: macro SWIG_SCILAB_ERROR (value 999 by default) for SWIG errors 2014-08-08 16:23:24 +02:00
Simon Marchetto
d89c2f15a0 scilab: use a macro instead of 999 for error code 2014-08-08 15:24:35 +02:00
Simon Marchetto
f665649658 scilab: apply boost_shared_ptr fix 2014-07-21 14:39:16 +02:00
Simon Marchetto
67f0f71f19 scilab: no need to use prefix "g_" for global names 2014-07-21 10:46:29 +02:00
Simon Marchetto
f365f8e820 scilab: coding style remove "_" from parameter names 2014-07-21 10:18:50 +02:00
Simon Marchetto
81879c0da8 scilab: coding style: remove "_" from parameter names 2014-07-10 15:13:27 +02:00
Simon Marchetto
bf5f761229 scilab: coding style: remove "_" from parameter names 2014-07-10 12:18:41 +02:00
Simon Marchetto
79e9421f29 scilab: fix typo error 2014-07-10 10:30:28 +02:00
Simon Marchetto
34db2b83c5 scilab: library stl.i include same libraries as in other languages 2014-07-10 09:22:32 +02:00
Simon Marchetto
540973ee1d scilab: code style: remove underscore in parameters (first part) 2014-07-09 18:32:52 +02:00
William S Fulton
f784d9feaa Remove author names - they are in the COPYRIGHT file 2014-06-26 20:30:25 +01:00
Simon Marchetto
27b5f47d7d scilab: fix commit fragment stdint 2014-06-26 10:04:29 +02:00
Simon Marchetto
821118de9b scilab: rename swig_this(), swig_ptr() to SWIG_this(), SWIG_ptr() 2014-06-26 09:44:49 +02:00
Simon Marchetto
89d9cdb1cd scilab: rename fragment 2014-06-26 09:27:25 +02:00
Simon Marchetto
8a2472c649 scilab: unsigned ints typemaps behave same as ints (2nd commit: arrays) 2014-06-16 16:25:49 +02:00
Simon Marchetto
e94dc0ca61 scilab: fix range checking in swig_this() 2014-06-16 12:07:09 +02:00
Simon Marchetto
72c6552c2d scilab: unsigned ints typemaps behave same as signed ints (1st commit: scalar) 2014-06-16 12:03:49 +02:00
Simon Marchetto
3ac0dc2be5 scilab: rename matrix typemaps named parameters 2014-06-13 16:21:21 +02:00
William S Fulton
610cefd25c Correct %include delimiters 2014-06-12 07:27:37 +01:00
Simon Marchetto
fb51700c3a scilab: add library cpointer.i (and test case) 2014-06-11 16:50:25 +02:00
Simon Marchetto
07b06a4089 Merge branch 'master' into gsoc2012-scilab
Conflicts:
	.gitignore
	.travis.yml
	COPYRIGHT
	Examples/Makefile.in
	Examples/test-suite/constructor_copy.i
	Makefile.in
	configure.ac
2014-06-06 16:33:16 +02:00
Simon Marchetto
8e4041478f scilab: fix Scilab variable creation for scilab 6 2014-06-05 18:34:19 +02:00
William S Fulton
c17f77750a Merge pull request #176 from v-for-vandal/lua_eq
Add default __eq implementation for Lua
2014-06-02 19:52:07 +01:00
Simon Marchetto
0b93dfe31f scilab: fix setApiContext macro for Scilab 5 2014-06-02 18:16:11 +02:00
William S Fulton
22be94d207 Fix std::vector<bool> compile problems on OSX for Javascript 2014-05-31 19:58:42 +01:00
Karl Wette
5c5510842b Octave: remove Python code from std_carray.i 2014-05-29 23:42:55 +02:00
Artem Serebriyskiy
4457d96e54 Moving variable declaration to the beginning of the block 2014-05-28 22:02:47 +04:00
Artem Serebriyskiy
2b4c49d017 Add default __eq implementation
* Renamed SWIG_Lua_equal to SWIG_Lua_class_equal
* If class has no __eq implemented, then default __eq is provided.
  Default __eq compares actual pointers stored inside Lua userdata
2014-05-28 22:01:23 +04:00
Olly Betts
703862dc3a Fix unused variable warning in Lua bindings 2014-05-28 23:04:06 +12: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
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
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
Olly Betts
1a0b8abec7 Fix comment typo 2014-05-24 11:11:51 +12:00