当前位置:网站首页>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.
边栏推荐
- [结构力学] 结点承载下影响线与直接承载下影响线不同的原因
- CTO and programmer were both sentenced because the crawler was out of control!
- Decorator Pattern
- 【HackTheBox】dancing(SMB)
- Cloud native annual technology inventory is released! Ride the wind and waves at the right time
- Research Report on the overall scale, major manufacturers, major regions, products and applications of high temperature film capacitors in the global market in 2022
- 什么是匿名内部类,如何使用匿名内部类
- [structural mechanics] the reason why the influence line under joint load is different from that under direct load
- Private project practice sharing gtlab+jenkins architecture construction and document reference
- Facade pattern
猜你喜欢

【HackTheBox】dancing(SMB)

Distributed transaction Seata

What are the circular statements of MySQL

网络设备设置/取消console口登陆单独密码

Facade pattern
![[structural mechanics] the reason why the influence line under joint load is different from that under direct load](/img/a6/fce0bb29cc5c84bc0ef20501617e06.png)
[structural mechanics] the reason why the influence line under joint load is different from that under direct load

Live broadcast appointment AWS data everywhere series activities

5000+ word interpretation | Product Manager: how to do a good job in component selection?

The subnet of the pool cannot be overlapped with that of other pools.

Easy to get started naturallanguageprocessing series topic 7 text classification based on fasttext
随机推荐
LabVIEW displays Unicode characters
什么是匿名内部类,如何使用匿名内部类
Continue yesterday's plan: February 16, 2022
Remediation for Unsafe Cryptographic Encryption
On February 15, the market hot money operation and the dragon and tiger list
波形记录仪MR6000的实时波形运算功能
[Verilog quick start of Niuke network question brushing series] ~ asynchronous reset Series T trigger
机器人强化学习——Transferring End-to-End Visuomotor Control from Simulation to RealWorld (CoRL 2017)
【代码随想录-动态规划】最长公共子序列
仿真与烧录程序有哪几种方式?(包含常用工具与使用方式)
Cucumber test practice
What are the ways to simulate and burn programs? (including common tools and usage)
Go Foundation (I)
What is an anonymous inner class and how to use it
Cloud native annual technology inventory is released! Ride the wind and waves at the right time
Le langage C imprime "Love", "Mars hit Earth" et ainsi de suite en utilisant printf, qui est constamment mis à jour
Force deduction solution summary 324- swing sequencing II
How to use the select statement of MySQL
Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of GPS antenna modules in the global market in 2022
【HackTheBox】dancing(SMB)