当前位置:网站首页>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.
边栏推荐
- ROS TF coordinate transformation Library & rewrite to create high frequency coordinate transformation broadcaster
- Service grid ASM year end summary: how do end users use the service grid?
- real time AI based system questionaires
- Gbase 8s must be a DBSA. Solution to failure to start due to path change
- Test content
- How to solve startup failure due to insufficient MySQL memory
- C language uses printf to print love, Mars strikes the earth, etc., which are constantly updated
- 开启生态新姿势 | 使用 WordPress 远程附件存储到 COS
- [IOT] description of renaming the official account "Jianyi commerce" to "product renweipeng"
- The 30th day of force deduction (DP topic)
猜你喜欢

How to use the select statement of MySQL

Annual inventory review of Alibaba cloud's observable practices in 2021

Remediation for Unsafe Cryptographic Encryption

Mysql 中的 mvcc原理

How to quickly install MySQL 5.7.17 under CentOS 6.5

泰克TDS3054B示波器技术指标

Flyweight pattern

How to create robots Txt file?

ROS TF coordinate transformation Library & rewrite to create high frequency coordinate transformation broadcaster

Template method pattern
随机推荐
Technical parameters of Tektronix DPO4104 digital fluorescence oscilloscope
How to display all MySQL databases
To learn more about Yibo Hongmeng development
How to create robots Txt file?
Research Report on the overall scale, major manufacturers, major regions, products and applications of power battery laser welding machines in the global market in 2022
机器人强化学习——第一人称 VS 第三人称
Accelerate the global cloud native layout, kyligence intelligent data cloud officially supports Google cloud
没遇到过这三个问题都不好意思说用过Redis
Network device setting / canceling console port login separate password
[code Capriccio - dynamic planning] longest common subsequence
系统分析师备考经验分享:分阶段、分重点
innography
Continue yesterday's plan: February 16, 2022
Cloud native annual technology inventory is released! Ride the wind and waves at the right time
JVM内存调优方式
An efficient flutter hybrid stack management scheme with zero intrusion, you deserve it!
Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of GPS antenna modules in the global market in 2022
February 14 institutional dragon and tiger list and operation of well-known hot money
[high concurrency] deeply analyze the callable interface
Research Report on the overall scale, major manufacturers, major regions, products and application segments of 5g modules of the Internet of things in the global market in 2022