예제 #1
0
/*
* Get an actionscript class with the given namespace and class name
* in the format: package::ClassName
*/
AS3_Val get_class(const char * as_namespaceclass_path)
{
  /* TODO: Merge with get_class2()? */

  AS3_Val as_namespace;
  AS3_Val as_class;
  AS3_Val ret;
  char * class_ptr = NULL;

  /* TODO might want to store classes in a table to save loading again */

  class_ptr = strstr(as_namespaceclass_path, "::");

  if (class_ptr > as_namespaceclass_path)
  {
    as_namespace = AS3_StringN(
        as_namespaceclass_path, (class_ptr - as_namespaceclass_path) / sizeof(char)
      );
    as_class = AS3_String(class_ptr + 2);
  }
  else
  {
    as_namespace = AS3_Undefined();
    as_class = AS3_String(as_namespaceclass_path);
  }

  ret = AS3_NSGet(as_namespace, as_class);

  /* TODO check for failure getting class */

  AS3_Release(as_namespace);
  AS3_Release(as_class);

  return ret;
}
예제 #2
0
QSP_BOOL qspCallIsPlayingFile(QSP_CHAR *file)
{
	/* Здесь проверяем, проигрывается ли файл */
	QSPCallState state;
	QSP_BOOL isPlaying;
	AS3_Val args;
	char *strUTF8;
	if (qspCallBacks[QSP_CALL_ISPLAYINGFILE].IsSet)
	{
		qspSaveCallState(&state, QSP_TRUE, QSP_FALSE);
		if (file)
		{
			strUTF8 = qspW2C(file);
			args = AS3_Array("StrType", strUTF8);
			free(strUTF8);
		}
		else
			args = AS3_Array("StrType", 0);
		AS3_Call(qspCallBacks[QSP_CALL_ISPLAYINGFILE].FuncVal, qspCallBacks[QSP_CALL_ISPLAYINGFILE].ThisVal, args);
		AS3_Release(args);
		flyield();
		isPlaying = (QSP_BOOL)AS3_IntValue(result);
		AS3_Release(result);
		qspRestoreCallState(&state);
		return isPlaying;
	}
	return QSP_FALSE;
}
예제 #3
0
QSP_CHAR *qspCallInputBox(QSP_CHAR *text)
{
	/* Здесь вводим текст */
	QSPCallState state;
	QSP_CHAR *buffer;
	AS3_Val args;
	char *strUTF8;
	char *resText;
	int maxLen = 511;
	if (qspCallBacks[QSP_CALL_INPUTBOX].IsSet)
	{
		qspSaveCallState(&state, QSP_TRUE, QSP_FALSE);
		if (text)
		{
			strUTF8 = qspW2C(text);
			args = AS3_Array("StrType", strUTF8);
			free(strUTF8);
		}
		else
			args = AS3_Array("StrType", 0);
		AS3_Call(qspCallBacks[QSP_CALL_INPUTBOX].FuncVal, qspCallBacks[QSP_CALL_INPUTBOX].ThisVal, args);
		AS3_Release(args);
		flyield();
		resText = AS3_StringValue(result);
		AS3_Release(result);
		buffer = qspC2W(resText);
		free(resText);
		qspRestoreCallState(&state);
	}
	else
		buffer = qspGetNewText(QSP_FMT(""), 0);
	return buffer;
}
예제 #4
0
/*
* Get an actionscript class with the given namespace and class name
* in the format: package (may be NULL), ClassName
*/
AS3_Val get_class2(const char * as_namespace_path, const char * as_class_path)
{
  AS3_Val as_namespace;
  AS3_Val as_class;
  AS3_Val ret;

  /* TODO might want to store classes in a table to save loading again */

  if (as_namespace_path)
  {
    as_namespace = AS3_String(as_namespace_path);
  }
  else
  {
    as_namespace = AS3_Undefined();
  }

  as_class = AS3_String(as_class_path);

  ret = AS3_NSGet(as_namespace, as_class);

  /* TODO check for failure getting class */

  AS3_Release(as_namespace);
  AS3_Release(as_class);

  return ret;
}
예제 #5
0
int main(int argc, char **argv)
{
	AS3_Val ilbc_lib = AS3_Object("");
	AS3_Val encodeMethod = AS3_FunctionAsync( NULL, (AS3_ThunkProc) encodeForFlash);
	AS3_Val decodeMethod = AS3_FunctionAsync( NULL, (AS3_ThunkProc) decodeForFlash);
	AS3_SetS(ilbc_lib, "encode", encodeMethod);
	AS3_SetS(ilbc_lib, "decode", decodeMethod);
	AS3_Release( encodeMethod );
	AS3_Release( decodeMethod );
	
	//No code below here. AS3_LibInit does not return
	AS3_LibInit( ilbc_lib );
	return 0;
}
예제 #6
0
/*
  TODO: Ugly workaround. Remove.
        See http://tinyurl.com/a9djb2
*/
BOOL is_null(AS3_Val val)
{
  BOOL result = FALSE;
  AS3_Val argsVal = AS3_Array("AS3ValType", val);
  AS3_Val classNameVal = AS3_Call(getQualifiedClassName_method, NULL, argsVal);
  AS3_Malloced_Str className = AS3_StringValue(classNameVal);
  AS3_Release(argsVal);
  AS3_Release(classNameVal);

  result = (strncmp(className, "null", 4) == 0);

  free(className);

  return result;
}
int main() {
	AS3_Val initparamMethod = AS3_Function( NULL, initparam );
	AS3_Val choosemodelMethod = AS3_Function( NULL, choosemodel );
	AS3_Val predictionMethod = AS3_FunctionAsync( NULL, prediction );
	
	AS3_Val result = AS3_Object( "initparam: AS3ValType, choosemodel: AS3ValType, prediction: AS3ValType", initparamMethod, choosemodelMethod, predictionMethod );

	AS3_Release( initparamMethod );
	AS3_Release( choosemodelMethod );
	AS3_Release( predictionMethod );
	
	AS3_LibInit( result );

	return 0;
}
예제 #8
0
파일: glue.c 프로젝트: huangyt/MyProjects
static AS3_Val thunk_InitBlockMap(void *gg_clientData, AS3_Val gg_args) {
	AS3_Val map;
	AS3_Val bytes;
	AS3_ArrayValue(gg_args, "AS3ValType, AS3ValType",  &map,  &bytes);
	AS3_Val blockCountVal = AS3_CallTS("readUnsignedInt", bytes, "");
	AS3_Val bitset = AS3_GetS(map, "bitset");
	
	AS3_SetS(map, "blockCount", blockCountVal);
	AS3_Release(AS3_CallTS("readBytes", bytes, "AS3ValType, IntType, IntType", bitset, 0, (int)((AS3_IntValue(blockCountVal) + 7) / 8)));
	
	AS3_Release(blockCountVal);
	AS3_Release(bitset);
	AS3_Release(map);
	AS3_Release(bytes);
	return NULL;
}
예제 #9
0
/*
 * Helpers
 */
int trace( const char *message )
{
  AS3_Val as3_message = AS3_String(message);
  AS3_Trace(as3_message);
  AS3_Release(as3_message);
  return 0;
}
예제 #10
0
void qspCallSaveGame(QSP_CHAR *file)
{
	/* Здесь позволяем пользователю выбрать файл */
	/* для сохранения состояния игры и сохраняем */
	/* в нем текущее состояние */
	QSPCallState state;
	AS3_Val args;
	char *strUTF8;
	if (qspCallBacks[QSP_CALL_SAVEGAMESTATUS].IsSet)
	{
		qspSaveCallState(&state, QSP_FALSE, QSP_TRUE);
		if (file)
		{
			strUTF8 = qspW2C(file);
			args = AS3_Array("StrType", strUTF8);
			free(strUTF8);
		}
		else
			args = AS3_Array("StrType", 0);
		AS3_Call(qspCallBacks[QSP_CALL_SAVEGAMESTATUS].FuncVal, qspCallBacks[QSP_CALL_SAVEGAMESTATUS].ThisVal, args);
		AS3_Release(args);
		flyield();
		qspRestoreCallState(&state);
	}
}
예제 #11
0
int resetPositionByteArray(AS3_Val byteArray)
{
	AS3_Val zero = AS3_Int(0);
	/* just reset the position */
	AS3_SetS((AS3_Val)byteArray, "position", zero);
	AS3_Release(zero);
	return 0;
}
예제 #12
0
파일: main.c 프로젝트: KosBeg/webp-plugin
int main()
{
	AS3_Val method = AS3_Function(NULL, call);
	AS3_Val result = AS3_Object("call: AS3ValType", method);
	AS3_Release(method);
	AS3_LibInit(result);
	return 0;
}
예제 #13
0
파일: glue.c 프로젝트: huangyt/MyProjects
static AS3_Val thunk_InitSubPiecePacket(void *gg_clientData, AS3_Val gg_args) {
	AS3_Val packet;
	AS3_Val bytes;
	AS3_ArrayValue(gg_args, "AS3ValType, AS3ValType",  &packet,  &bytes);
	AS3_Val subpiece = AS3_GetS(packet, "subpiece");
	AS3_Val blockIndexVal = AS3_CallTS("readUnsignedShort", bytes, "");
	AS3_Val subPieceIndexVal = AS3_CallTS("readUnsignedShort", bytes, "");
	
	AS3_SetS(subpiece, "blockIndex", blockIndexVal);
	AS3_SetS(subpiece, "subPieceIndex", subPieceIndexVal);
	
	AS3_Release(subpiece);
	AS3_Release(blockIndexVal);
	AS3_Release(subPieceIndexVal);
	AS3_Release(packet);
	AS3_Release(bytes);
	return NULL;
}
예제 #14
0
파일: main.c 프로젝트: Glideh/jfrec
int closeByteArray(void * cookie)
{
	AS3_Val zero = AS3_Int(0);
	
	/* just reset the position */
	AS3_SetS((AS3_Val)cookie, "position", zero);
	AS3_Release(zero);
	return 0;
}
예제 #15
0
AS3_Val initializeMaterial( void* self, AS3_Val args )
{
	Material * material;

	AS3_Val ambient, diffuse, specular, emissive;

	double a_a, a_r, a_g, a_b, d_a, d_r, d_g, d_b, s_a, s_r, s_g, s_b, e_a, e_r, e_g, e_b, power;

	AS3_ArrayValue( args, "AS3ValType, AS3ValType, AS3ValType, AS3ValType, DoubleType", &ambient, &diffuse, &specular, &emissive, &power );

	a_r = AS3_NumberValue( AS3_GetS( ambient, "redMultiplier" ) );
	a_g = AS3_NumberValue( AS3_GetS( ambient, "greenMultiplier" ) );
	a_b = AS3_NumberValue( AS3_GetS( ambient, "blueMultiplier" ) );
	a_a = AS3_NumberValue( AS3_GetS( ambient, "alphaMultiplier" ) );

	d_r = AS3_NumberValue( AS3_GetS( diffuse, "redMultiplier" ) );
	d_g = AS3_NumberValue( AS3_GetS( diffuse, "greenMultiplier" ) );
	d_b = AS3_NumberValue( AS3_GetS( diffuse, "blueMultiplier" ) );
	d_a = AS3_NumberValue( AS3_GetS( diffuse, "alphaMultiplier" ) );

	s_r = AS3_NumberValue( AS3_GetS( specular, "redMultiplier" ) );
	s_g = AS3_NumberValue( AS3_GetS( specular, "greenMultiplier" ) );
	s_b = AS3_NumberValue( AS3_GetS( specular, "blueMultiplier" ) );
	s_a = AS3_NumberValue( AS3_GetS( specular, "alphaMultiplier" ) );

	e_r = AS3_NumberValue( AS3_GetS( emissive, "redMultiplier" ) );
	e_g = AS3_NumberValue( AS3_GetS( emissive, "greenMultiplier" ) );
	e_b = AS3_NumberValue( AS3_GetS( emissive, "blueMultiplier" ) );
	e_a = AS3_NumberValue( AS3_GetS( emissive, "alphaMultiplier" ) );

	material = newMaterial( newColor888( (BYTE)(a_r * 255), (BYTE)(a_g * 255), (BYTE)(a_b * 255), (BYTE)(a_a * 255) ),
							newColor888( (BYTE)(d_r * 255), (BYTE)(d_g * 255), (BYTE)(d_b * 255), (BYTE)(d_a * 255) ),
							newColor888( (BYTE)(s_r * 255), (BYTE)(s_g * 255), (BYTE)(s_b * 255), (BYTE)(s_a * 255) ),
							newColor888( (BYTE)(e_r * 255), (BYTE)(e_g * 255), (BYTE)(e_b * 255), (BYTE)(e_a * 255) ),
							power );

	AS3_Release( ambient );
	AS3_Release( diffuse );
	AS3_Release( specular );
	AS3_Release( emissive );

	return AS3_Array( "PtrType, PtrType, PtrType, PtrType, PtrType, PtrType, PtrType", material, material->ambient, material->diffuse, material->specular, material->emissive, &material->power, &material->doubleSide );
}
예제 #16
0
파일: osint.c 프로젝트: zhuowei/vecx
int main (int argc, char **argv) {

	AS3_Val initMethod = AS3_Function(NULL, flash_init);
	AS3_Val tickMethod = AS3_Function(NULL, flash_tick);
	AS3_Val resetMethod = AS3_Function(NULL, flash_reset);

	AS3_Val vecxemu = AS3_Object(
		"init:AS3ValType, tick:AS3ValType, reset:AS3ValType", 
		initMethod, tickMethod, resetMethod
	);

	AS3_Release( initMethod );
	AS3_Release( tickMethod );
	AS3_Release( resetMethod );

	AS3_LibInit(vecxemu);

	return 0;
}
예제 #17
0
파일: main.c 프로젝트: Glideh/jfrec
int main(int argc, char **argv)
{
    print_header();
	
	// set convert & update methods visible to flash
	AS3_Val convertMethod = AS3_Function( NULL, init );
	AS3_Val updateMethod = AS3_Function( NULL, update );
	
	AS3_Val result = AS3_Object( "init:AS3ValType, update: AS3ValType", convertMethod, updateMethod );
	
	AS3_Release( convertMethod );
	AS3_Release( updateMethod );
	
	// notify that we initialized -- THIS DOES NOT RETURN!
	AS3_LibInit( result );
	
    return 0;
	 
} 
예제 #18
0
int qspCallShowMenu()
{
	/* «десь показываем меню */
	QSPCallState state;
	int index;
	AS3_Val args;
	if (qspCallBacks[QSP_CALL_SHOWMENU].IsSet)
	{
		qspSaveCallState(&state, QSP_FALSE, QSP_TRUE);
		args = AS3_Array("");
		AS3_Call(qspCallBacks[QSP_CALL_SHOWMENU].FuncVal, qspCallBacks[QSP_CALL_SHOWMENU].ThisVal, args);
		AS3_Release(args);
		flyield();
		index = AS3_IntValue(result);
		AS3_Release(result);
		qspRestoreCallState(&state);
		return index;
	}
	return -1;
}
예제 #19
0
int qspCallGetMSCount()
{
	/* Здесь получаем количество миллисекунд, прошедших с момента последнего вызова функции */
	QSPCallState state;
	int count;
	AS3_Val args;
	if (qspCallBacks[QSP_CALL_GETMSCOUNT].IsSet)
	{
		qspSaveCallState(&state, QSP_TRUE, QSP_FALSE);
		args = AS3_Array("");
		AS3_Call(qspCallBacks[QSP_CALL_GETMSCOUNT].FuncVal, qspCallBacks[QSP_CALL_GETMSCOUNT].ThisVal, args);
		AS3_Release(args);
		flyield();
		count = AS3_IntValue(result);
		AS3_Release(result);
		qspRestoreCallState(&state);
		return count;
	}
	return 0;
}
예제 #20
0
파일: webpdf.c 프로젝트: emcmanus/WebPDF
int main(int argc, char **argv)
{
	// Create callbacks
	AS3_Val setupMethod = AS3_Function(NULL, f_setup);
	AS3_Val tickMethod = AS3_Function(NULL, f_tick);
	AS3_Val quitApplicationMethod = AS3_Function(NULL, f_teardown);
	
  AS3_Val libPDF = AS3_Object(
		"setup:AS3ValType, tick:AS3ValType, quit:AS3ValType", 
		setupMethod, tickMethod, quitApplicationMethod
	);
    
	AS3_Release( setupMethod );
	AS3_Release( tickMethod );
	AS3_Release( quitApplicationMethod );
	
  AS3_LibInit(libPDF);
	
	return (0);
}
예제 #21
0
파일: glue.c 프로젝트: huangyt/MyProjects
static AS3_Val thunk_InitPeerDownloadInfo(void *gg_clientData, AS3_Val gg_args) {
	AS3_Val info;
	AS3_Val bytes;
	AS3_ArrayValue(gg_args, "AS3ValType, AS3ValType",  &info,  &bytes);	
	AS3_Val isDownloadingVal = AS3_CallTS("readUnsignedByte", bytes, "");
	
	if (AS3_IntValue(isDownloadingVal) == 1)
	{
		AS3_Val true = AS3_True();
		AS3_SetS(info, "isDownloading", true);
		AS3_Release(true);
	}
	else
	{
		AS3_Val false = AS3_False();
		AS3_SetS(info, "isDownloading", false);
		AS3_Release(false);
	}
	
	AS3_Val onLineTimeVal = AS3_CallTS("readUnsignedInt", bytes, "");
	AS3_Val avgDownloadVal = AS3_CallTS("readUnsignedShort", bytes, "");
	AS3_Val nowDownloadVal = AS3_CallTS("readUnsignedShort", bytes, "");
	AS3_Val avgUploadVal = AS3_CallTS("readUnsignedShort", bytes, "");
	AS3_Val nowUploadVal = AS3_CallTS("readUnsignedShort", bytes, "");
	AS3_SetS(info, "onLineTime", onLineTimeVal);
	AS3_SetS(info, "avgDownload", avgDownloadVal);
	AS3_SetS(info, "nowDownload", nowDownloadVal);
	AS3_SetS(info, "avgUpload", avgUploadVal);
	AS3_SetS(info, "nowUpload", nowUploadVal);
	AS3_ByteArray_seek(bytes, 3, 1);	// ignore 3 byte reserved bytes	
	
	AS3_Release(isDownloadingVal);
	AS3_Release(onLineTimeVal);
	AS3_Release(avgDownloadVal);
	AS3_Release(nowDownloadVal);
	AS3_Release(avgUploadVal);
	AS3_Release(nowUploadVal);	
	AS3_Release(bytes);
	AS3_Release(info);
	return NULL;
}
예제 #22
0
파일: JsFlashC.c 프로젝트: cyrta/JsFlashC
//entry point for code
int main()
{
	AS3_Val echoMethod = AS3_Function(NULL, echo);

    AS3_Val result = AS3_Object("echo: AS3ValType", echoMethod);

    AS3_Release(echoMethod);

    AS3_LibInit(result);
	// should never get here!
	return 0;
}
예제 #23
0
/*
 * CLib Setup
 */
int main(int argc, char **argv)
{
	// Build CLib and return control to Flash
	AS3_Val setupMethod = AS3_Function(NULL, setup);
	AS3_Val tickMethod = AS3_Function(NULL, tick);
	AS3_Val getDisplayPointerMethod = AS3_Function(NULL, getDisplayPointer);
	AS3_Val cleanupMethod = AS3_Function(NULL, cleanup);
	
  AS3_Val libGL = AS3_Object(
		"setup:AS3ValType, tick:AS3ValType, getDisplayPointer:AS3ValType, cleanup:AS3ValType", 
		setupMethod,       tickMethod,      getDisplayPointerMethod,      cleanupMethod
	);
  
	AS3_Release( setupMethod );
	AS3_Release( tickMethod );
	AS3_Release( getDisplayPointerMethod );
	AS3_Release( cleanupMethod );
  
  AS3_LibInit(libGL);
  
  return 0;
}
예제 #24
0
int main(int argc, char *argv[])
{
     // regular function
	 AS3_Val doAesVal = AS3_Function(NULL, doAes);
	 
	 // async function
	 AS3_Val doUnAesVal = AS3_Function(NULL, doUnAes);
	 
	 AS3_Val doDecodeVal = AS3_Function(NULL,doDecode);

	 // construct an object that holds refereces to the 2 functions
	 AS3_Val result = AS3_Object("doAes: AS3ValType, doUnAes: AS3ValType,doDecode:AS3ValType",
	 doAesVal, doUnAesVal,doDecodeVal);

	 AS3_Release(doAesVal);
	 AS3_Release(doUnAesVal);
	 AS3_Release(doDecodeVal);

	 // notify that we initialized -- THIS DOES NOT RETURN!
	 AS3_LibInit(result);

	 return 0;
}
예제 #25
0
void qspCallShowMenu()
{
	/* Здесь показываем меню */
	QSPCallState state;
	AS3_Val args;
	if (qspCallBacks[QSP_CALL_SHOWMENU].IsSet)
	{
		qspSaveCallState(&state, QSP_FALSE, QSP_TRUE);
		args = AS3_Array("");
		AS3_Call(qspCallBacks[QSP_CALL_SHOWMENU].FuncVal, qspCallBacks[QSP_CALL_SHOWMENU].ThisVal, args);
		AS3_Release(args);
		flyield();
		qspRestoreCallState(&state);
	}
}
예제 #26
0
void qspCallSetTimer(int msecs)
{
	/* Здесь устанавливаем интервал таймера */
	QSPCallState state;
	AS3_Val args;
	if (qspCallBacks[QSP_CALL_SETTIMER].IsSet)
	{
		qspSaveCallState(&state, QSP_TRUE, QSP_FALSE);
		args = AS3_Array("IntType", msecs);
		AS3_Call(qspCallBacks[QSP_CALL_SETTIMER].FuncVal, qspCallBacks[QSP_CALL_SETTIMER].ThisVal, args);
		AS3_Release(args);
		flyield();
		qspRestoreCallState(&state);
	}
}
예제 #27
0
void qspCallRefreshInt(QSP_BOOL isRedraw)
{
	/* Здесь выполняем обновление интерфейса */
	QSPCallState state;
	AS3_Val args;
	if (qspCallBacks[QSP_CALL_REFRESHINT].IsSet)
	{
		qspSaveCallState(&state, QSP_TRUE, QSP_FALSE);
		args = AS3_Array("IntType", isRedraw);
		AS3_Call(qspCallBacks[QSP_CALL_REFRESHINT].FuncVal, qspCallBacks[QSP_CALL_REFRESHINT].ThisVal, args);
		AS3_Release(args);
		flyield();
		qspRestoreCallState(&state);
	}
}
예제 #28
0
void qspCallShowWindow(int type, QSP_BOOL isShow)
{
	/* Здесь показываем или скрываем окно */
	QSPCallState state;
	AS3_Val args;
	if (qspCallBacks[QSP_CALL_SHOWWINDOW].IsSet)
	{
		qspSaveCallState(&state, QSP_TRUE, QSP_FALSE);
		args = AS3_Array("IntType, IntType", type, isShow);
		AS3_Call(qspCallBacks[QSP_CALL_SHOWWINDOW].FuncVal, qspCallBacks[QSP_CALL_SHOWWINDOW].ThisVal, args);
		AS3_Release(args);
		flyield();
		qspRestoreCallState(&state);
	}
}
예제 #29
0
void qspCallDeleteMenu()
{
	/* Здесь удаляем текущее меню */
	QSPCallState state;
	AS3_Val args;
	if (qspCallBacks[QSP_CALL_DELETEMENU].IsSet)
	{
		qspSaveCallState(&state, QSP_TRUE, QSP_FALSE);
		args = AS3_Array("");
		AS3_Call(qspCallBacks[QSP_CALL_DELETEMENU].FuncVal, qspCallBacks[QSP_CALL_DELETEMENU].ThisVal, args);
		AS3_Release(args);
		flyield();
		qspRestoreCallState(&state);
	}
}
예제 #30
0
void qspCallSleep(int msecs)
{
	/* Здесь ожидаем заданное количество миллисекунд */
	QSPCallState state;
	AS3_Val args;
	if (qspCallBacks[QSP_CALL_SLEEP].IsSet)
	{
		qspSaveCallState(&state, QSP_TRUE, QSP_FALSE);
		args = AS3_Array("IntType", msecs);
		AS3_Call(qspCallBacks[QSP_CALL_SLEEP].FuncVal, qspCallBacks[QSP_CALL_SLEEP].ThisVal, args);
		AS3_Release(args);
		flyield();
		qspRestoreCallState(&state);
	}
}