当前位置:网站首页>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()
三:代码下载:
边栏推荐
- Seata aggregates at, TCC, Saga and XA transaction modes to create a one-stop distributed transaction solution
- GPS從入門到放弃(十三)、接收機自主完好性監測(RAIM)
- GPS from getting started to giving up (19), precise ephemeris (SP3 format)
- PVL EDI project case
- Adjustable DC power supply based on LM317
- Learn the principle of database kernel from Oracle log parsing
- Data processing skills (7): MATLAB reads the data in the text file TXT with mixed digital strings
- Lora sync word settings
- lora同步字设置
- Crawler obtains real estate data
猜你喜欢
Spatial domain and frequency domain image compression of images
Seata aggregates at, TCC, Saga and XA transaction modes to create a one-stop distributed transaction solution
Wechat red envelope cover applet source code - background independent version - source code with evaluation points function
GPS from getting started to giving up (XIII), receiver autonomous integrity monitoring (RAIM)
Attack and defense world ditf Misc
0 basic learning C language - interrupt
【数字IC手撕代码】Verilog无毛刺时钟切换电路|题目|原理|设计|仿真
[MySQL] online DDL details
GPS从入门到放弃(十六)、卫星时钟误差和卫星星历误差
Management background --4, delete classification
随机推荐
Heavyweight news | softing fg-200 has obtained China 3C explosion-proof certification to provide safety assurance for customers' on-site testing
[leetcode daily clock in] 1020 Number of enclaves
剪映+json解析将视频中的声音转换成文本
[linear algebra] determinant of order 1.3 n
CCNA-思科网络 EIGRP协议
Management background --4, delete classification
Qt | UDP广播通信、简单使用案例
GNN,请你的网络层数再深一点~
PVL EDI project case
BarcodeX(ActiveX打印控件) v5.3.0.80 免费版使用
anaconda安装第三方包
第3章:类的加载过程(类的生命周期)详解
Embedded common computing artifact excel, welcome to recommend skills to keep the document constantly updated and provide convenience for others
自制J-Flash烧录工具——Qt调用jlinkARM.dll方式
2022-07-04 mysql的高性能数据库引擎stonedb在centos7.9编译及运行
Wechat red envelope cover applet source code - background independent version - source code with evaluation points function
中国VOCs催化剂行业研究与投资战略报告(2022版)
GNN, please deepen your network layer~
Lora sync word settings
2500个常用中文字符 + 130常用中英文字符