Dev Checkpoint 201906252113
This commit is contained in:
parent
2a8cb127ec
commit
e7993dca97
3 changed files with 79 additions and 107 deletions
9
Examples/test-suite/javascript/native_directive_runme.js
Normal file
9
Examples/test-suite/javascript/native_directive_runme.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
var native_directive = require("native_directive");
|
||||
|
||||
(function main() {
|
||||
var s = "abc.DEF-123";
|
||||
if (native_directive.CountAlphas(s) !== 6)
|
||||
throw "CountAlphas failed";
|
||||
if (native_directive.CountAlphaCharacters(s) !== 6)
|
||||
throw "CountAlphaCharacters failed";
|
||||
})();
|
||||
|
|
@ -42,32 +42,58 @@ extern "C" JNIEXPORT jint JNICALL Java_native_1directive_native_1directiveJNI_Co
|
|||
#endif
|
||||
|
||||
|
||||
#if defined(SWIG_V8_VERSION)
|
||||
|
||||
#ifdef SWIGJAVASCRIPT
|
||||
%native(CountAlphaCharacters) void JavaScript_alpha_count();
|
||||
%{
|
||||
static SwigV8ReturnValue wrap_alpha_count(const SwigV8Arguments &args) {
|
||||
#ifdef SWIG_V8_VERSION /* engine = node || v8 */
|
||||
|
||||
static SwigV8ReturnValue JavaScript_alpha_count(const SwigV8Arguments &args) {
|
||||
SWIGV8_HANDLESCOPE();
|
||||
v8::Handle<v8::Value> jsresult;
|
||||
char *arg1 = (char *) 0 ;
|
||||
int res1 ;
|
||||
char *buf1 = 0 ;
|
||||
int alloc1 = 0 ;
|
||||
char *arg1 = (char *)0;
|
||||
int res1;
|
||||
char *buf1 = 0;
|
||||
int alloc1 = 0;
|
||||
int result;
|
||||
if(args.Length() != 1) SWIG_exception_fail(SWIG_ERROR,
|
||||
"Illegal number of arguments for _wrap_count_characters.");
|
||||
if(args.Length() != 1) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for _wrap_alpha_count.");
|
||||
res1 = SWIG_AsCharPtrAndSize(args[0], &buf1, NULL, &alloc1);
|
||||
if (!SWIG_IsOK(res1)) {
|
||||
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "count_characters"
|
||||
"', argument " "1"" of type '" "char const *""'");
|
||||
}
|
||||
if (!SWIG_IsOK(res1))
|
||||
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "alpha_count" "', argument " "1"" of type '" "char const *""'");
|
||||
arg1 = reinterpret_cast< char * >(buf1);
|
||||
result = (int)count_characters((char const *)arg1);
|
||||
result = (int)alpha_count((char const *)arg1);
|
||||
jsresult = SWIG_From_int(static_cast< int >(result));
|
||||
if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
|
||||
SWIGV8_RETURN(jsresult);
|
||||
fail:
|
||||
SWIGV8_RETURN(SWIGV8_UNDEFINED());
|
||||
}
|
||||
%}
|
||||
%native(CountAlphaCharacters) void wrap_alpha_count();
|
||||
#endif
|
||||
|
||||
#else /* engine = jsc */
|
||||
|
||||
static JSValueRef JavaScript_alpha_count(JSContextRef context, JSObjectRef function,
|
||||
JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)
|
||||
{
|
||||
char *arg1 = (char *)0;
|
||||
int res1;
|
||||
char *buf1 = 0;
|
||||
int alloc1 = 0;
|
||||
int result;
|
||||
JSValueRef jsresult;
|
||||
if (argc != 1) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments.");
|
||||
res1 = SWIG_JSC_AsCharPtrAndSize(context, argv[0], &buf1, NULL, &alloc1);
|
||||
if (!SWIG_IsOK(res1))
|
||||
SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "alpha_count" "', argument " "1"" of type '" "char const *""'");
|
||||
arg1 = reinterpret_cast< char * >(buf1);
|
||||
result = (int)alpha_count((char const *)arg1);
|
||||
jsresult = SWIG_From_int SWIG_JSC_FROM_CALL_ARGS(static_cast< int >(result));
|
||||
if (alloc1 == SWIG_NEWOBJ) delete[] buf1;
|
||||
return jsresult;
|
||||
fail:
|
||||
return JSValueMakeUndefined(context);
|
||||
}
|
||||
|
||||
#endif /* engine */
|
||||
%}
|
||||
#endif /* SWIGJAVASCRIPT */
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue