Пример #1
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;
}
Пример #2
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;
}
Пример #3
0
/*
* Get a string and its size in bytes from given AS3 string.
* To push to Lua multibyte string, you should know not its length
* (as in str.length), but its size in bytes.
* You may pass NULL as size_in_bytes.
* It is up to you to call free() on returned pointer.
*/
AS3_Malloced_Str get_string_bytes(AS3_Val strValue, size_t * size_in_bytes)
{
  AS3_Malloced_Str str = AS3_StringValue(strValue);
  if (size_in_bytes != NULL)
  {
    /*
    * Note strlen() not mbstrlen().
    * We should get size in bytes, not in characters.
    */
    /*
    * TODO: UGLY HACK! Support embedded zeroes somehow.
    */
    *size_in_bytes = strlen(str);
  }
  return str;
}