| 1 |
/** |
|---|
| 2 |
* The Actionscript Byte Code eXecutable translation tool for MacOS X |
|---|
| 3 |
* |
|---|
| 4 |
* @author Copyright (c) 2008 daoki2 |
|---|
| 5 |
* @version 1.0.0 |
|---|
| 6 |
* @link http://snippets.libspark.org/ |
|---|
| 7 |
* @link http://homepage.mac.com/daoki2/ |
|---|
| 8 |
* |
|---|
| 9 |
* Copyright (c) 2008 daoki2 |
|---|
| 10 |
* |
|---|
| 11 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|---|
| 12 |
* of this software and associated documentation files (the "Software"), to deal |
|---|
| 13 |
* in the Software without restriction, including without limitation the rights |
|---|
| 14 |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|---|
| 15 |
* copies of the Software, and to permit persons to whom the Software is |
|---|
| 16 |
* furnished to do so, subject to the following conditions: |
|---|
| 17 |
* |
|---|
| 18 |
* The above copyright notice and this permission notice shall be included in |
|---|
| 19 |
* all copies or substantial portions of the Software. |
|---|
| 20 |
* |
|---|
| 21 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|---|
| 22 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|---|
| 23 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|---|
| 24 |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|---|
| 25 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|---|
| 26 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|---|
| 27 |
* THE SOFTWARE. |
|---|
| 28 |
*/ |
|---|
| 29 |
|
|---|
| 30 |
import avmplus.System; |
|---|
| 31 |
|
|---|
| 32 |
var args:Array = System.argv; |
|---|
| 33 |
|
|---|
| 34 |
if (args.length != 1) { |
|---|
| 35 |
trace('Usage: abcx filename.abc'); |
|---|
| 36 |
} else { |
|---|
| 37 |
var code:String = new Array( |
|---|
| 38 |
"#include <stdlib.h>", |
|---|
| 39 |
"#include <stdio.h>", |
|---|
| 40 |
"#include <string.h>", |
|---|
| 41 |
"", |
|---|
| 42 |
"int main(int argc, char *argv[])", |
|---|
| 43 |
"{", |
|---|
| 44 |
" static const char cmd[] = \"avmplus " + args[0] + "\";", |
|---|
| 45 |
" int len = 0;", |
|---|
| 46 |
" int i = 0;", |
|---|
| 47 |
" char *args;", |
|---|
| 48 |
" if (argc > 1) {", |
|---|
| 49 |
" for (i = 1; i < argc; i++) {", |
|---|
| 50 |
" len += strlen(argv[i]);", |
|---|
| 51 |
" }", |
|---|
| 52 |
" len += argc + 2 + strlen(cmd);", |
|---|
| 53 |
" args = malloc(len + argc + 4 + strlen(cmd));", |
|---|
| 54 |
" strcpy(args, cmd);", |
|---|
| 55 |
" strcat(args, \" -- \");", |
|---|
| 56 |
" for (i = 1; i < argc; i++) {", |
|---|
| 57 |
" strcat(args, argv[i]);", |
|---|
| 58 |
" strcat(args, \" \");", |
|---|
| 59 |
" }", |
|---|
| 60 |
" } else {", |
|---|
| 61 |
" args = malloc(strlen(cmd));", |
|---|
| 62 |
" strcpy(args, cmd);", |
|---|
| 63 |
" }", |
|---|
| 64 |
" system(args);", |
|---|
| 65 |
"}" |
|---|
| 66 |
).join("\n"); |
|---|
| 67 |
trace(code); |
|---|
| 68 |
} |
|---|