如何将 alchemy asm 声明的变量引用到 flash 中?
我在 alchemy asm 中声明了一个变量:
asm("var buffer:Vector.<Number> = new Vector.<Number>(100, true);");
我可以用这样的数据填充它:
asm("buffer[%0] = %1;" : : "r"(index) : "r"(value));
我不知道如何将该 asm“缓冲区”变量的引用获取到动作脚本中。
(我确实想到了一种方法......我所做的是从炼金术asm中抛出“缓冲区”,然后在actionscript中捕获它,但不幸的是它似乎泄漏了大量内存)。
有更好的替代方法吗?
请注意,性能至关重要,使用默认的 Alchemy 编组速度太慢。
i have a variable declared in alchemy asm:
asm("var buffer:Vector.<Number> = new Vector.<Number>(100, true);");
i can populate it with data like so:
asm("buffer[%0] = %1;" : : "r"(index) : "r"(value));
what i can't figure out is how to get a reference of that asm "buffer" variable into actionscript.
(i did think of one way... what i did was to throw the "buffer" from alchemy asm, and then catch it in actionscript, but unfortunately it seems to leak a lot of memory).
is there a better alternative to doing this?
please note that performance is critical, and using default alchemy marshaling is way too slow.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
asm
仅用于来回传递数字,这意味着我们必须使用 Alchemy 的内部 int 到对象映射。深入研究中间 AS3 代码(要查看它,请将ACHACKS_TMPS
环境变量设置为“1”),似乎是CTypemap.AS3ValType
执行映射。因此,您可以返回一个由 asm 创建的对象,如下所示:注意:虽然这是有趣的黑客行为,但它可能不是解决此问题的最佳方法。这可能不是从 Alchemy 获取数据并存入 Flash 的最快方法。为此,我建议使用 ByteArray 将数据复制到 Alchemy 的 RAM 中或从 Alchemy 的 RAM 中复制出来。请参阅此SO问题了解该领域的一些技术。
asm
is only for passing numbers back and forth, which means we'll have to use Alchemy's internal int-to-object mappings. Digging through the intermediate AS3 code (to see it, set theACHACKS_TMPS
environment variable to '1'), it seems thatCTypemap.AS3ValType
does the mapping. So you can return an asm-created object like this:Note: While this is fun hackery, it might not be the best way to solve this problem. This is probably not the fastest way to get data out of Alchemy and into Flash. For that, I suggest using a ByteArray to copy data into and out of Alchemy's RAM. See this SO question for some techniques in that area.