当前位置:网站首页>New d reflection generates ABI of C for class
New d reflection generates ABI of C for class
2022-06-29 04:50:00 【fqbqrr】
mixin template CWrapper(Type) {
import std.traits;
export extern(C):
pragma(mangle, "create_" ~ __traits(identifier, Type))
void* creator(Parameters!(Type.__ctor) args) {
return cast(void*)new Type(args);
}
mixin(() {
string ret;
foreach(m; __traits(allMembers, Type)) {
static if (m != "__ctor" && m != "__dtor" && isFunction!(__traits(getMember, Type, m))) {
ret ~= `ReturnType!(__traits(getMember, Type, "` ~ m ~ `")) ` ~ __traits(identifier, Type) ~ `_` ~ m ~ `(void* obj, Parameters!(__traits(getMember, Type, "` ~ m ~ `")) args) { return (cast(Type)obj).` ~ m ~ `(args); }`;
}
}
return ret;
}());
}
class Foo {
int x;
this(int x) { this.x = x; }
int getX() { return x; }
}
mixin CWrapper!(Foo);
// GENERATED CODE:
extern(C) {
void* create_Foo(int); // returns void* to Foo instance
int Foo_getX(void*); // takes void* to Foo instance
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
- 28.
- 29.
- 30.
- 31.
- 32.
- 33.
- 34.
- 35.
by arbitrarily D class Generate C Of ABI.
边栏推荐
- Mvcc principle in MySQL
- Set column width in jitter - set column width in jitter
- Visitor pattern
- Untitled
- Use typescript compiler parameter 'skiplibcheck' - usage of the typescript compiler argument'skiplibcheck'
- Is the interviewer too difficult to serve? A try catch asks so many tricks
- Accelerate the global cloud native layout, kyligence intelligent data cloud officially supports Google cloud
- Template method pattern
- [code Capriccio - dynamic planning] longest common subsequence
- [IOT] description of renaming the official account "Jianyi commerce" to "product renweipeng"
猜你喜欢
![[high concurrency] deeply analyze the callable interface](/img/42/43d1f0b894f2632f2c7f1bfe970708.jpg)
[high concurrency] deeply analyze the callable interface

Iterator pattern
![[IOT] description of renaming the official account](/img/54/43189f34b81a7441cd46d5c2066970.png)
[IOT] description of renaming the official account "Jianyi commerce" to "product renweipeng"

Open source demo| you draw and I guess -- make your life more interesting

How to display all MySQL databases

be based on. NETCORE development blog project starblog - (13) add friendship link function

软件体系结构实验汇总

Quelles sont les méthodes de simulation et de gravure des programmes? (comprend les outils communs et la façon dont ils sont utilisés)

如何用万用表测试电子部件

Untitled
随机推荐
[code Capriccio - dynamic planning] longest common subsequence
[hackthebox] dancing (SMB)
Remediation for Unsafe Cryptographic Encryption
Complete collection of necessary documents for project management: you can't write these 14 project documents yet?
ROS URDF model is parsed into KDL tree
Real time waveform calculation function of Waveform Recorder mr6000
网传广东一名学生3次考上北大,3年共赚200万元奖金
【HackTheBox】dancing(SMB)
Redis notes (II) operating commands for keys in redis
Actual combat! Another opening method of magic modified swagger and knife4j
Distributed transaction Seata
Use typescript compiler parameter 'skiplibcheck' - usage of the typescript compiler argument'skiplibcheck'
C語言用 printf 打印 《愛心》《火星撞地球》等,不斷更新
20年秦皇島D - Exam Results(二分+思維,附易錯數據)
MySQL subquery
Set column width in jitter - set column width in jitter
What are the circular statements of MySQL
LabVIEW displays Unicode characters
[high concurrency] deeply analyze the callable interface
How to change the password of mysql8 created by docker