当前位置:网站首页>Aardio - 封装库时批量处理属性与回调函数的方法
Aardio - 封装库时批量处理属性与回调函数的方法
2022-07-06 14:39:00 【卢光庆】
关于封装库时批量处理属性与回调函数的方法,在
《 Aardio - 回调函数的方法解析_卢光庆的博客-CSDN博客_aardio函数手册 》
一文中提及,就是所谓的“光庆回调法”。
因上文中没有一整套系统的示例代码,只看代码片段,可能比较难理解,所以应部分aardio朋友需求,在此整理了一套具体示例代码,以供参考:
一、dll中的处理方法:
以易语言为例:



二、aardio中进行声明与调用的方法:
import console;
var dll = ..raw.loadDll("/test.dll");
//定义设置属性的函数
var setp = dll.api("setProp","bool(string,string)")
setProp = function(prop,v){ //因为易语言编译的dll为ansi编码,所以传递参数时要进行转码。
if type(v)=type.table v=..table.tostring(v);
return setp(..string.fromto(prop,65001,0),..string.fromto(tostring(v),65001,0));
}
//定义获取属性的函数
var getp = dll.api("getProp","ptr(string)")
getProp = function(prop){ //因为易语言编译的dll为ansi编码,所以传递参数时要进行转码。
var str = ..raw.str(getp(..string.fromto(prop,65001,0)));
str = ..string.fromto(str,0,65001);
return eval(str);
}
//定义回调函数
var callback = function(funcname,param){
funcname = ..string.fromto(funcname,0,65001);
if console[funcname] return console[funcname](..table.unpack(eval(..string.fromto(param,0,65001))));
}
var _stdfunc = ..raw.tostdcall(callback,"int(string,string)");
dll.setcallback(tonumber(..raw.toPointer(_stdfunc)));
//*******************开始测试
//测试属性
//理论上来说,多少属性都可以,在aardio里不用逐个处理。在dll中处理好就可以。
setProp("prop1","我是文本型属性") //文本
setProp("prop2",123456) //数值
setProp("prop3",true) //逻辑
setProp("prop4",{123,{1,2,3},"abc",true}) //数组
console.dump(getProp("prop1"), type(getProp("prop1")))
console.dump(getProp("prop2"), type(getProp("prop2")))
console.dump(getProp("prop3"), type(getProp("prop3")))
console.dump(getProp("prop4"), type(getProp("prop4")))
//测试回调
//定义三个aardio回调函数,关键是这三个回调函数并未转为stdcall,而是通过一个callback回调函数执行。
//理论上来说,多少回调函数都可以,在aardio里不用逐个处理。在dll随便调用即可。
console.func1 = function(v){
console.dump("回调执行============",'\n',v)
}
console.func2 = function(v){
console.dump("回调执行============",'\n',(v*10)+567)
}
console.func3 = function(a,b,c,d){
console.dump("回调执行============",'\n',a,(b+1)*1123,c,!c,d,d[2])
}
//模拟回调,调用三个回调函数
dll.testcallback()
console.pause(true);
fsys.remove()三:代码下载:
边栏推荐
- NetXpert XG2帮您解决“布线安装与维护”难题
- Applet system update prompt, and force the applet to restart and use the new version
- 小常识:保险中的“保全”是什么?
- GPS从入门到放弃(十一)、差分GPS
- i. Mx6ull build boa server details and some of the problems encountered
- The SQL response is slow. What are your troubleshooting ideas?
- [sciter]: encapsulate the notification bar component based on sciter
- Data processing skills (7): MATLAB reads the data in the text file TXT with mixed digital strings
- UNI-Admin基础框架怎么关闭创建超级管理员入口?
- OpenCV VideoCapture. Get() parameter details
猜你喜欢

GPS從入門到放弃(十三)、接收機自主完好性監測(RAIM)
![[MySQL] online DDL details](/img/7e/97098d7ed5802c446bbadaf7035981.png)
[MySQL] online DDL details

Unity3d Learning Notes 6 - GPU instantiation (1)

第3章:类的加载过程(类的生命周期)详解

Oracle-控制文件及日志文件的管理

2022年6月国产数据库大事记-墨天轮

Mise en place d'un environnement de développement OP - tee basé sur qemuv8

二分图判定

UNI-Admin基础框架怎么关闭创建超级管理员入口?

2500 common Chinese characters + 130 common Chinese and English characters
随机推荐
QT | UDP broadcast communication, simple use case
Seata aggregates at, TCC, Saga and XA transaction modes to create a one-stop distributed transaction solution
图像的spatial domain 和 frequency domain 图像压缩
Set status bar style demo
Insert sort and Hill sort
GD32F4XX串口接收中断和闲时中断配置
Chapter 4: talk about class loader again
GPS from getting started to giving up (12), Doppler constant speed
十二、启动流程
Management background --5, sub classification
Support multiple API versions in flask
二叉(搜索)树的最近公共祖先 ●●
HDU 4912 paths on the tree (lca+)
Attack and defense world miscall
GNN,请你的网络层数再深一点~
2022-07-05 stonedb的子查询处理解析耗时分析
中国固态氧化物燃料电池技术进展与发展前景报告(2022版)
labelimg的安装与使用
硬件開發筆記(十): 硬件開發基本流程,制作一個USB轉RS232的模塊(九):創建CH340G/MAX232封裝庫sop-16並關聯原理圖元器件
Unity3d minigame-unity-webgl-transform插件转换微信小游戏报错To use dlopen, you need to use Emscripten‘s...问题