当前位置:网站首页>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 :
边栏推荐
- 做接口测试都测什么?有哪些通用测试点?
- hdu 5077 NAND(暴力打表)
- 12、 Start process
- volatile关键字
- Pit encountered by handwritten ABA
- Build op-tee development environment based on qemuv8
- OpenNMS分离数据库
- China 1,4-cyclohexanedimethanol (CHDM) industry research and investment decision-making report (2022 Edition)
- npm无法安装sharp
- Aardio - 不声明直接传float数值的方法
猜你喜欢
(十八)LCD1602实验
Spatial domain and frequency domain image compression of images
Learn the principle of database kernel from Oracle log parsing
pytorch_ Yolox pruning [with code]
网络基础入门理解
基于 QEMUv8 搭建 OP-TEE 开发环境
Adavit -- dynamic network with adaptive selection of computing structure
labelimg的安装与使用
[leetcode daily clock in] 1020 Number of enclaves
二分图判定
随机推荐
Installation and use of labelimg
2014阿里巴巴web前实习生项目分析(1)
C# 三种方式实现Socket数据接收
手写ABA遇到的坑
i. Mx6ull build boa server details and some of the problems encountered
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
Mise en place d'un environnement de développement OP - tee basé sur qemuv8
基于 QEMUv8 搭建 OP-TEE 开发环境
Unity3d minigame-unity-webgl-transform插件转换微信小游戏报错To use dlopen, you need to use Emscripten‘s...问题
剑指offer刷题记录1
SQL server generates auto increment sequence number
Gd32f4xx serial port receive interrupt and idle interrupt configuration
枚举与#define 宏的区别
Spatial domain and frequency domain image compression of images
机试刷题1
Assembly and Interface Technology Experiment 6 - ADDA conversion experiment, AD acquisition system in interrupt mode
自制J-Flash烧录工具——Qt调用jlinkARM.dll方式
Volatile keyword
CocosCreator+TypeScripts自己写一个对象池
three.js绚烂的气泡效果