0

您好,您能否提供一个如何在 adobe alchemy 中解析 xml 文件的示例。我正在尝试在 expat 上工作,但是在将字节数组传入和传出 c 代码时我没有运气。

我需要将文件的字节数组传递给炼金术,还是足以传递文件名。

谢谢。

哥伦比亚广播公司

4

2 回答 2

1

If you want to parse xml within Alchemy, you'll need to use a C/C++ parsing library.

As for getting the xml into Alchemy:

  • The simplest way would be to simply pass the xml string into the function and Alchemy will marshal it for you.
  • Alternatively you could use supplyFile/fopen to open a "virtual file" that maps to a ByteArray.
  • You could also copy the ByteArray straight into Alchemy's RAM.

Here is a comparison of methods to move ByteArrays into Alchemy.

于 2010-09-01T16:29:01.633 回答
0

这是我传递嵌入文件的方式:

[Embed(source="Test.txt", mimeType="application/octet-stream")] public var TestClass:Class;

私有函数 echo():String { var loader:CLibInit=new CLibInit; var lib:Object = loader.init() var data:Object = new TestClass(); lib.test(data.length, 数据); }

C代码是:

静态 AS3_Val test(void *self, AS3_Val args) { int length; AS3_Val 数据=AS3_Undefined(); AS3_ArrayValue(args, "IntType, AS3ValType", &length, &data)

无符号字符缓冲区[长度];AS3_ByteArray_seek(缓冲区,0,SEEK_SET);}

于 2010-11-23T12:48:48.290 回答