当前位置:网站首页>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 :
边栏推荐
- pytorch_ Yolox pruning [with code]
- Spatial domain and frequency domain image compression of images
- GD32F4XX串口接收中断和闲时中断配置
- 基於 QEMUv8 搭建 OP-TEE 開發環境
- 【雅思口语】安娜口语学习记录part1
- MySQL ---- first acquaintance with MySQL
- MySQL教程的天花板,收藏好,慢慢看
- Daily question 1: force deduction: 225: realize stack with queue
- NPDP certification | how do product managers communicate across functions / teams?
- 做接口测试都测什么?有哪些通用测试点?
猜你喜欢

剑指offer刷题记录1

Aardio - 通过变量名将变量值整合到一串文本中

LeetCode 练习——剑指 Offer 26. 树的子结构

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

Config:invalid signature solution and troubleshooting details

Self made j-flash burning tool -- QT calls jlinkarm DLL mode

Chapter 4: talk about class loader again

CCNA Cisco network EIGRP protocol

Senior soft test (Information System Project Manager) high frequency test site: project quality management
![[Digital IC hand tearing code] Verilog burr free clock switching circuit | topic | principle | design | simulation](/img/2b/15b3d831bba6aa772ad83f3ac91d23.png)
[Digital IC hand tearing code] Verilog burr free clock switching circuit | topic | principle | design | simulation
随机推荐
Clip +json parsing converts the sound in the video into text
0 basic learning C language - interrupt
重磅新闻 | Softing FG-200获得中国3C防爆认证 为客户现场测试提供安全保障
Heavyweight news | softing fg-200 has obtained China 3C explosion-proof certification to provide safety assurance for customers' on-site testing
C# 三种方式实现Socket数据接收
Signed and unsigned keywords
[线性代数] 1.3 n阶行列式
Notes de développement du matériel (10): flux de base du développement du matériel, fabrication d'un module USB à RS232 (9): création de la Bibliothèque d'emballage ch340g / max232 SOP - 16 et Associa
Pit encountered by handwritten ABA
Aardio - 通过变量名将变量值整合到一串文本中
What are the interface tests? What are the general test points?
three.js绚烂的气泡效果
Report on technological progress and development prospects of solid oxide fuel cells in China (2022 Edition)
Inno Setup 打包及签名指南
每日一题:力扣:225:用队列实现栈
That's why you can't understand recursion
uniapp设置背景图效果demo(整理)
在IPv6中 链路本地地址的优势
UDP编程
2022-07-05 use TPCC to conduct sub query test on stonedb