当前位置:网站首页>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()三:代码下载:
边栏推荐
- Build op-tee development environment based on qemuv8
- [Digital IC hand tearing code] Verilog burr free clock switching circuit | topic | principle | design | simulation
- Common sense: what is "preservation" in insurance?
- 小程序系统更新提示,并强制小程序重启并使用新版本
- 十二、启动流程
- GPS from getting started to giving up (XVIII), multipath effect
- C # réalise la liaison des données du rapport Crystal et l'impression du Code à barres 4
- The SQL response is slow. What are your troubleshooting ideas?
- Applet system update prompt, and force the applet to restart and use the new version
- Memorabilia of domestic database in June 2022 - ink Sky Wheel
猜你喜欢

【sciter】: 基于 sciter 封装通知栏组件

GPS from getting started to giving up (19), precise ephemeris (SP3 format)

二分图判定

基於 QEMUv8 搭建 OP-TEE 開發環境

Crawler obtains real estate data
![[线性代数] 1.3 n阶行列式](/img/6e/54f3a994fc4c2c10c1036bee6715e8.gif)
[线性代数] 1.3 n阶行列式

GNN, please deepen your network layer~

GPS从入门到放弃(十二)、 多普勒定速

Wechat red envelope cover applet source code - background independent version - source code with evaluation points function

Oracle-控制文件及日志文件的管理
随机推荐
Xiaoman network model & http1-http2 & browser cache
Management background --1 Create classification
【sciter】: 基于 sciter 封装通知栏组件
GPS from entry to abandonment (XVII), tropospheric delay
qt quick项目offscreen模式下崩溃的问题处理
Maximum product of three numbers in question 628 of Li Kou
Save and retrieve strings
VIP case introduction and in-depth analysis of brokerage XX system node exceptions
[sciter]: encapsulate the notification bar component based on sciter
GPS from getting started to giving up (19), precise ephemeris (SP3 format)
C#实现水晶报表绑定数据并实现打印4-条形码
The SQL response is slow. What are your troubleshooting ideas?
[10:00 public class]: basis and practice of video quality evaluation
Memorabilia of domestic database in June 2022 - ink Sky Wheel
PVL EDI 项目案例
i.mx6ull搭建boa服务器详解及其中遇到的一些问题
Management background --4, delete classification
AI enterprise multi cloud storage architecture practice | Shenzhen potential technology sharing
AI enterprise multi cloud storage architecture practice | Shenzhen potential technology sharing
基於 QEMUv8 搭建 OP-TEE 開發環境