当前位置:网站首页>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()
三:代码下载:
边栏推荐
- Inno Setup 打包及签名指南
- 小常识:保险中的“保全”是什么?
- 3DMAX assign face map
- 剪映+json解析将视频中的声音转换成文本
- GPS from entry to abandonment (XVII), tropospheric delay
- BarcodeX(ActiveX打印控件) v5.3.0.80 免费版使用
- [10:00 public class]: basis and practice of video quality evaluation
- [sdx62] wcn685x will bdwlan Bin and bdwlan Txt mutual conversion operation method
- MariaDB database management system learning (I) installation diagram
- Unity3d minigame-unity-webgl-transform插件转换微信小游戏报错To use dlopen, you need to use Emscripten‘s...问题
猜你喜欢
数据处理技巧(7):MATLAB 读取数字字符串混杂的文本文件txt中的数据
Common sense: what is "preservation" in insurance?
微信红包封面小程序源码-后台独立版-带测评积分功能源码
基于 QEMUv8 搭建 OP-TEE 开发环境
Mise en place d'un environnement de développement OP - tee basé sur qemuv8
嵌入式常用计算神器EXCEL,欢迎各位推荐技巧,以保持文档持续更新,为其他人提供便利
Data processing skills (7): MATLAB reads the data in the text file TXT with mixed digital strings
C#实现水晶报表绑定数据并实现打印4-条形码
Management background --1 Create classification
0 basic learning C language - digital tube
随机推荐
将MySQL的表数据纯净方式导出
2500 common Chinese characters + 130 common Chinese and English characters
2022-07-05 stonedb的子查询处理解析耗时分析
重磅新闻 | Softing FG-200获得中国3C防爆认证 为客户现场测试提供安全保障
414. The third largest digital buckle
[sciter]: encapsulate the notification bar component based on sciter
GPS從入門到放弃(十三)、接收機自主完好性監測(RAIM)
Kohana database
SQL Server生成自增序号
GPS从入门到放弃(十三)、接收机自主完好性监测(RAIM)
Applet system update prompt, and force the applet to restart and use the new version
2022-07-04 mysql的高性能数据库引擎stonedb在centos7.9编译及运行
中国1,4-环己烷二甲醇(CHDM)行业调研与投资决策报告(2022版)
[Digital IC hand tearing code] Verilog burr free clock switching circuit | topic | principle | design | simulation
12、 Start process
【数字IC手撕代码】Verilog无毛刺时钟切换电路|题目|原理|设计|仿真
C # realizes crystal report binding data and printing 4-bar code
Search element topic (DFS)
Lora sync word settings
PVL EDI project case