当前位置:网站首页>Aardio - Method of batch processing attributes and callback functions when encapsulating Libraries
Aardio - Method of batch processing attributes and callback functions when encapsulating Libraries
2022-07-06 22:31:00 【Lu Guangqing】
About the method of batch processing attributes and callback functions when encapsulating libraries , stay
《 Aardio - Method parsing of callback function _ Luguangqing's blog -CSDN Blog _aardio Function manual 》
It is mentioned in the article that , It's called “ Guangqing callback method ”.
Because there is no example code of a complete system in the above , Just look at code snippets , It may be difficult to understand , So it should be partially aardio Friend needs , A set of specific example code is sorted out here , For reference :
One 、dll How to deal with :
Take Yi language as an example :
Two 、aardio Methods declared and called in :
import console;
var dll = ..raw.loadDll("/test.dll");
// Define functions that set properties
var setp = dll.api("setProp","bool(string,string)")
setProp = function(prop,v){ // Because easy language compilation dll by ansi code , Therefore, transcoding is required when passing parameters .
if type(v)=type.table v=..table.tostring(v);
return setp(..string.fromto(prop,65001,0),..string.fromto(tostring(v),65001,0));
}
// Define the function to get properties
var getp = dll.api("getProp","ptr(string)")
getProp = function(prop){ // Because easy language compilation dll by ansi code , Therefore, transcoding is required when passing parameters .
var str = ..raw.str(getp(..string.fromto(prop,65001,0)));
str = ..string.fromto(str,0,65001);
return eval(str);
}
// Define callback function
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)));
//******************* Start testing
// Test attribute
// In theory , Any number of attributes can , stay aardio There is no need to deal with it one by one . stay dll You can deal with it in .
setProp("prop1"," I am a text attribute ") // Text
setProp("prop2",123456) // The number
setProp("prop3",true) // Logic
setProp("prop4",{123,{1,2,3},"abc",true}) // Array
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")))
// Test callback
// Define three aardio Callback function , The key is that these three callback functions are not converted to stdcall, But through a callback Callback function execution .
// In theory , Any number of callback functions can , stay aardio There is no need to deal with it one by one . stay dll Just call it at will .
console.func1 = function(v){
console.dump(" Callback execution ============",'\n',v)
}
console.func2 = function(v){
console.dump(" Callback execution ============",'\n',(v*10)+567)
}
console.func3 = function(a,b,c,d){
console.dump(" Callback execution ============",'\n',a,(b+1)*1123,c,!c,d,d[2])
}
// Analog callback , Call three callback functions
dll.testcallback()
console.pause(true);
fsys.remove()
3、 ... and : The code download :
边栏推荐
- rust知识思维导图xmind
- (18) LCD1602 experiment
- Sword finger offer question brushing record 1
- 软考高级(信息系统项目管理师)高频考点:项目质量管理
- return 关键字
- Spatial domain and frequency domain image compression of images
- 手写ABA遇到的坑
- Inno setup packaging and signing Guide
- NPDP certification | how do product managers communicate across functions / teams?
- 柔性数组到底如何使用呢?
猜你喜欢
leetcode:面试题 17.24. 子矩阵最大累加和(待研究)
在IPv6中 链路本地地址的优势
硬件開發筆記(十): 硬件開發基本流程,制作一個USB轉RS232的模塊(九):創建CH340G/MAX232封裝庫sop-16並關聯原理圖元器件
Sword finger offer question brushing record 1
Aardio - 利用customPlus库+plus构造一个多按钮组件
2022-07-04 the high-performance database engine stonedb of MySQL is compiled and run in centos7.9
0 basic learning C language - interrupt
0 basic learning C language - digital tube
NPDP认证|产品经理如何跨职能/跨团队沟通?
软考高级(信息系统项目管理师)高频考点:项目质量管理
随机推荐
extern关键字
Unity3d minigame unity webgl transform plug-in converts wechat games to use dlopen, you need to use embedded 's problem
手写ABA遇到的坑
POJ 1258 Agri-Net
Senior soft test (Information System Project Manager) high frequency test site: project quality management
LeetCode 练习——剑指 Offer 26. 树的子结构
NPDP certification | how do product managers communicate across functions / teams?
新手程序员该不该背代码?
hdu 5077 NAND(暴力打表)
Web APIs DOM time object
(18) LCD1602 experiment
UDP programming
[leetcode] 19. Delete the penultimate node of the linked list
Hardware development notes (10): basic process of hardware development, making a USB to RS232 module (9): create ch340g/max232 package library sop-16 and associate principle primitive devices
NetXpert XG2帮您解决“布线安装与维护”难题
pytorch_ Yolox pruning [with code]
MySQL----初识MySQL
2022-07-05 使用tpcc对stonedb进行子查询测试
【无标题】
Aardio - 通过变量名将变量值整合到一串文本中