forked from adobe-flash/crossbridge
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alex Macdonald
committed
Apr 25, 2013
1 parent
d0433db
commit 9f490cd
Showing
56 changed files
with
5,403 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) 2013 Adobe Systems Inc | ||
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
|
||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
// regressiong test for ALC699 | ||
// compile with: | ||
// alchemy/sdk/usr/bin/gcc -pthread -emit-swf ALC699.c -o ALC699.swf | ||
|
||
#include <AS3/AVM2.h> | ||
#include <pthread.h> | ||
#include <stdio.h> | ||
|
||
static void *threadProc(void *arg) | ||
{ | ||
sleep(90); | ||
*(int *)arg = 1; | ||
return NULL; | ||
} | ||
|
||
static void *nopProc(void *arg) | ||
{ | ||
return arg; | ||
} | ||
|
||
int main() | ||
{ | ||
volatile int stop = 0; | ||
pthread_t thread; | ||
pthread_create(&thread, NULL, threadProc, (int *)&stop); | ||
printf("start (test duration ~91s -- ensure this amount of time will trip the script timeout in your player AND that you're running a debugger player [so you'll see the exception!])\n"); | ||
sleep(1); | ||
while(!stop) | ||
avm2_ui_thunk(nopProc, NULL); | ||
pthread_join(thread, NULL); | ||
printf("done\n"); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright (c) 2013 Adobe Systems Inc | ||
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
|
||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#include <AS3/AS3.h> | ||
#include <AS3/AS3++.h> | ||
#include <Flash++.h> | ||
|
||
int main() | ||
{ | ||
AS3::local::var v; | ||
AS3_DeclareVar(someString, String); | ||
inline_nonreentrant_as3("someString = 'foo'"); | ||
AS3_GetVarxxFromVar(v, someString); | ||
AS3::local::internal::trace(v); | ||
v = AS3::local::internal::new_String("baz"); | ||
AS3_CopyVarxxToVar(someString, v); | ||
AS3_Trace(someString); | ||
|
||
v = AS3::local::internal::new_Number(3.4); | ||
AS3::local::internal::trace(v); | ||
AS3::local::var cc; | ||
AS3_DeclareVar(intCC, Class); | ||
inline_nonreentrant_as3("intCC = int"); | ||
AS3_GetVarxxFromVar(cc, intCC); | ||
v = AS3::local::internal::coerce(cc, v); | ||
AS3::local::internal::trace(v); | ||
|
||
v = AS3::local::flash::utils::Dictionary::internal::getClosure(); | ||
v = AS3::local::internal::new_Vector(v); | ||
AS3::local::internal::trace(v["constructor"]); | ||
v[0] = AS3::local::flash::utils::Dictionary::_new(); | ||
AS3::local::internal::trace(v); | ||
try | ||
{ | ||
v[0] = AS3::local::internal::new_Number(3.4); // should throw! | ||
} | ||
catch(AS3::local::var e) | ||
{ | ||
AS3::local::internal::trace(e); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright (c) 2013 Adobe Systems Inc | ||
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
|
||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#include <pthread.h> | ||
extern "C" { | ||
#include <sys/thr.h> | ||
} | ||
#include <AS3/AS3++.h> | ||
#include <AS3/AVM2.h> | ||
|
||
using namespace AS3::ui; | ||
|
||
int expectedDepth = 0; | ||
int successes = 0; | ||
int EXPECTED_SUCCESSES = 20; | ||
|
||
static var recurseProc(void *arg, var args) | ||
{ | ||
var callee = args[0]; | ||
int depth = internal::int_valueOf(args[1]); | ||
|
||
if(depth) | ||
{ | ||
printf("depth: %d\n", depth); | ||
|
||
if( depth == expectedDepth-- ){ | ||
++successes; | ||
} | ||
|
||
var rargs[] = { callee, internal::new_int(depth-1) }; | ||
internal::call(callee, internal::_undefined, 2, rargs); | ||
} | ||
return internal::_undefined; | ||
} | ||
|
||
static var fun = internal::new_Function(recurseProc, NULL); | ||
static var fargs[] = { fun, internal::new_int(10) }; | ||
|
||
static char cond; | ||
|
||
static void *threadProc(void *arg) | ||
{ | ||
internal::call(fun, internal::_undefined, 2, fargs); | ||
avm2_wake_one(&cond); | ||
return NULL; | ||
} | ||
|
||
int main() | ||
{ | ||
printf("self\n"); | ||
expectedDepth = 10; | ||
internal::call(fun, internal::_undefined, 2, fargs); | ||
printf("thread\n"); | ||
expectedDepth = 10; | ||
pthread_t thread; | ||
pthread_create(&thread, NULL, threadProc, NULL); | ||
avm2_self_msleep(&cond, 0); | ||
pthread_join(thread, NULL); | ||
printf("ok!\n"); | ||
if( successes == EXPECTED_SUCCESSES ){ | ||
printf("RESULT=PASS"); | ||
}else{ | ||
printf("RESULT=FAIL"); | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) 2013 Adobe Systems Inc | ||
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
|
||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#include <pthread.h> | ||
#include <AS3/AS3++.h> | ||
#include <AS3/AVM2.h> | ||
|
||
static char mouseThreadExitCond; | ||
|
||
using namespace AS3::ui; | ||
|
||
static var mouseMoveEventListener(void *data, var args) | ||
{ | ||
var event = args[0]; | ||
printf("mouseMove!\n"); | ||
return internal::_undefined; | ||
} | ||
|
||
static void *mouseThreadProc(void *arg) | ||
{ | ||
var stage = internal::get_Stage(); | ||
var elArgs[] = { internal::new_String("mouseMove"), internal::new_Function(mouseMoveEventListener, NULL) }; | ||
internal::call(stage["addEventListener"], stage, 2, elArgs); | ||
|
||
avm2_self_msleep(&mouseThreadExitCond, 0); | ||
|
||
internal::call(stage["removeEventListener"], stage, 2, elArgs); | ||
return NULL; | ||
} | ||
|
||
int main() | ||
{ | ||
pthread_t mouseThread; | ||
pthread_create(&mouseThread, NULL, mouseThreadProc, NULL); | ||
pthread_join(mouseThread, NULL); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) 2013 Adobe Systems Inc | ||
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
|
||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#include <pthread.h> | ||
extern "C" { | ||
#include <sys/thr.h> | ||
} | ||
#include <AS3/AVM2.h> | ||
#include <stdio.h> | ||
|
||
static char cond; | ||
|
||
extern "C" int tprintf(const char *tmpl, ...); | ||
|
||
static void *wakeThunk(void *arg) | ||
{ | ||
return (void *)avm2_wake_one(arg); | ||
} | ||
|
||
static void *threadProc(void *arg) | ||
{ | ||
avm2_thr_impersonate((long)arg, wakeThunk, &cond); | ||
return NULL; | ||
} | ||
|
||
int main() | ||
{ | ||
pthread_t thread; | ||
long id; | ||
|
||
thr_self(&id); | ||
pthread_create(&thread, NULL, threadProc, (void *)id); | ||
tprintf("sleeping!\n"); | ||
avm2_self_msleep(&cond, 0); | ||
tprintf("ok!\n"); | ||
pthread_join(thread, NULL); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (c) 2013 Adobe Systems Inc | ||
|
||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
|
||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
|
||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
#include <pthread.h> | ||
extern "C" { | ||
#include <sys/thr.h> | ||
} | ||
#include <AS3/AS3++.h> | ||
#include <AS3/AVM2.h> | ||
|
||
using namespace AS3::ui; | ||
|
||
static char cond; | ||
|
||
static void *threadProc(void *arg) | ||
{ | ||
avm2_wake_one(&cond); | ||
return NULL; | ||
} | ||
|
||
static pthread_t thread; | ||
|
||
static var timeoutProc(void *arg, var args) | ||
{ | ||
pthread_create(&thread, NULL, threadProc, NULL); | ||
return internal::_undefined; | ||
} | ||
|
||
int main() | ||
{ | ||
var namespaceClass = internal::getlex(internal::new_String("Namespace")); | ||
var flash_utils = internal::construct(namespaceClass, internal::new_String("flash.utils")); | ||
var setTimeout = internal::getlex(flash_utils, internal::new_String("setTimeout")); | ||
var stArgs[] = { internal::new_Function(timeoutProc, NULL), internal::new_int(3000) }; | ||
internal::call(setTimeout, internal::_undefined, 2, stArgs); | ||
printf("sleeping!\n"); | ||
avm2_self_msleep(&cond, 0); | ||
pthread_join(thread, NULL); | ||
printf("ok!\n"); | ||
return 0; | ||
} |
Oops, something went wrong.