flasCC技术点记录
[待测试特性]
一、C接口导出相关
1、重载函数。
2、虚函数。
3、template相关
二、内存相关
1、as直接往c分配的内存写数据。
2、c直接往as对象写数据。
三、C访问AS
1、访问as中的基本类型变量
2、访问as中的复杂类型变量
3、访问as中的function对象
4、inline assembly. 官方文档说明如下:
The interop between AS3 and C/C++ in FlasCC is based around the concept of inline assembly. In a native C/C++ workflow you would use inline assembly statements to allow you to pass arbitrary strings containing platform specific instructions to the assembler to be included in your final executable. With FlasCC the underlying system is the Flash Runtime, and the language it supports natively is AS3, so these inline assembly statements let you talk to the native Flash API set in the language it was designed with.
其中有两种常用的macro, inline_as3
和 package_as3
。用法如下:
#include <AS3/AS3.h> // Use AS3 to sqrt a double!
double somenumber = 45.0;
double result = 0.0;
inline_as3(
"%0 = Math.sqrt(%1);\n"
: "=r"(result) : "r"(somenumber)
); // Back in C we can take the result and print it out:
printf("sqrt of %f is %f\n", somenumber, result);
package_as3("#package public\n var somepublicvar:int = 42;");
package_as3("#package private\n var someprivatevar:int = 42;");
package_as3("#package com.example.yourpackage\n var somespecialvar:int = 42;");
四、AS访问C
五、多线程(pthread与worker)
adobe官方对于pthread的说明:
http://www.adobe.com/devnet/games/articles/pthreads-flascc.html
其中有一段话很重要:
Flascc Pthreads are implemented using ActionScript workers. Creation of a Pthread causes the creation of an AS3 Worker object on which the Pthread start_routine
runs. Workers created for Pthread execution automatically share C memory with other Pthreads including the main Pthread. Global and static variables are shared between Pthreads. Therefore, C data—including pointers to scalars, function pointers, and so on—can be safely shared between Pthreads. However, AS3 values are not shared between workers and therefore are not generally shareable between Pthreads.
六、flascc中比较难理解的接口和系统概念
1、flascc模块的初始化入口
和c程序类似, 一个flascc模块建议使用一个main函数作为其入口。
AS3_GoAsync宏
When breaking a C/C++ run-loop so that FlasCC code is suitable for use without using multi-threading you need to execute main, so the static initializers for your code are run, but you want to prevent the static destructors from running so it is important that main does not return. By throwing an AS3 exception and preserving the stack we can effectively interrupt the execution of main.
2、as中对于flascc模块的加载
要使用一个flascc编写的模块swc, 在使用之前要对其进行加载, 也就是初始化, 这个要利用CModule来操作。 对于CModule要说明的是, 每一个flascc模块swc都有一个唯一对应的CModule类, 利用这个类可以对与之对应的swc进行操作,比如初始化, 读写内存等。
七、系统模块说明
1、CModule
1.1 初始化接口
1.1.1 start()
Calls the libc __start1
function which, in turn, causes main()
to execute.
1.1.2 startAsync()
Calls the libc __start1
function which, in turn, causes main()
to execute. Unlike start()
, this method handles the case where the main C run loop has been broken by a call to "AS3_GoAsync" within the C code. This allows main to return without allowing C/C++ static initializers to run. This should be used when you want to run long running code with a broken run-loop, or run some code as a library.
1.1.3 startBackground()
Creates a background Worker and runs the libc function __start1
within that Worker. This allows you to run main without breaking the run loop, but requires the SWF to be version 18 or higher (Flash Runtime 11.5).
这三个接口的参数一致, 如下:
Parameters
console:Object (default = null) — The current Console object
args:Vector.<String> (default = null) — A vector of Strings that are used to fill the argv array given to main. The first String is typically used to specify the name of the application.
env:Vector.<String> (default = null) — A vector of Strings that are used to populate the environment variables accesible by getenv(). There should be an even number of Strings in this Vector as they are treated as name/value pairs.
afterStackSize:int (default = 65536) — The amount of stack space to allocate for the ui thread (code that will run the uiThunk callbacks and also any calls to callI coming from the main Worker).
1.2 property
1.2.1 rootSprite
如果仅仅是在一个单线程里加载并使用flascc模块, 随便new sprite给这个属性就好。
奇怪的是,如果在flascc模块里用到pthread创建另外一个线程, 如果rootSprite的loadInfo为空的话, 就会报错。这就意味着必须用根sprite或者一个动态加载的swf才能赋给这个属性。
2、Console
3、IVFS
4、ISpecialFile
5、IKernel
flasCC技术点记录的更多相关文章
- Qt:小项目仿QQ修改头像界面,技术点记录
最近写了一个修改头像功能的UI,布局参考了QQ目前的修改头像界面.如下图 这里主要说明一下两个地方的技术:1.头像图片上层的遮罩层,圆形外部为灰色,内部为全透明:2.上传图片宽高比例可以通过鼠标拖拽移 ...
- (转)java缓存技术,记录
http://blog.csdn.net/madun/article/details/8569860 最近再ITEYE上看到关于讨论JAVA缓存技术的帖子比较多,自己不懂,所以上网大概搜了下,找到一篇 ...
- 微博与Redis系统技术文章记录
Redis 持久化,有两种: rdb 和 aof, rdb是记录一段时间内的操作,一盘的配置是一段时间内操作超过多少次就持久化. aof可以实现每次操作都持久化. 这里我们使用aof. 配置方式,打开 ...
- android 技术点记录
Android Service完全解析,关于服务你所需知道的一切(上) http://blog.csdn.net/guolin_blog/article/details/11952435 androi ...
- php页面静态化技术;学习笔记
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 四项技术 助你提高SQL Server的性能
有时,为了让应用程序运行得更快,所做的全部工作就是在这里或那里做一些很小调整.但关键在于确定如何进行调整!迟早您会遇到这种情况:应用程序中的 SQL 查询不能按照您想要的方式进行响应.它要么不返回数据 ...
- TCPDump:捕获并记录特定协议 / 端口
Q. 如何使用 Linux / UNIX 平台下的 TCPDump 工具捕获特定协议或端口比如 80 (http)?如何使用 TCPDump 将流记录下来,然后(根据记录)查找到问题所在? ...
- JavaWeb学习笔记五 会话技术Cookie&Session
什么是会话技术? 例如网站的购物系统,用户将购买的商品信息存储到哪里?因为Http协议是无状态的,也就是说每个客户访问服务器端资源时,服务器并不知道该客户端是谁,所以需要会话技术识别客户端的状态.会话 ...
- 会话技术、Cookie技术与Session技术
一.会话技术 1. 存储客户端状态 会话技术是帮助服务器记住客户端状态(区分客户端)的. 2. 会话技术 从打开一个浏览器访问某个站点,到关闭这个浏览器的整个过程,称为一次会话.会话技术就是记录这 ...
随机推荐
- Bootstrap——基本模板
<!DOCTYPE html><html lang="zh-cn"> <head> <meta charset="utf ...
- XML 增删改查
<?php $xmlpatch = 'index.xml'; $_id = '; $_title = 'title1'; $_content = 'content1'; $_author = ' ...
- CALayer的分析
转载地址: http://my.oschina.net/u/2340880/blog/536048 iOS开发CoreAnimation解读之二——对CALayer的分析 一.UIView中的CAL ...
- python3.5.1语法
1.print (变量名) print("字符串") 2.a=1 id(a)返回a在内存中的地址 3.可以用table弹出提示 #coding:utf-8 4.输入3/2 结果 ...
- CString.Format
Cstring str: str.Format("%d",num); d输出带符号十进制数 o输出无符号八进制数 x输出无符号十六进制数 u输出无符号数 c输出单个字符 s输出一串 ...
- Objective C 基础
1,字符串加@: 不加@的是C语言字符串. 加@的代表的是OC的NSString http://www.jikexueyuan.com/course/71_2.html 2,setValuesForK ...
- Cheatsheet: 2013 08.20 ~ 08.31
.NET Protobuf-net: the unofficial manual 5 Common C# Misconceptions What is new in the Mono project ...
- jenkins远程命令执行利用工具
昨天看小飞侠写的py的jenkins的脚本,昨天晚上在微信里评论今天写一个JAVA的GUI的tools. 早上花了点时间写一下: code: package com.tools; import jav ...
- CUBRID学习笔记 13 日志文件
欢迎转载 ,转载时请保留作者信息.本文版权归本人所有,如有任何问题,请与我联系wang2650@sohu.com . 过错 CUBRID Broker Log Files 可以理解为数据库中间件日志 ...
- hdu 5925 Coconuts 离散化+dfs
Coconuts Time Limit: 9000/4500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem ...