Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lievenhey committed Sep 14, 2021
0 parents commit e88abac
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
d_demangle:
dmd -c demangle.d
dmd -oflibd_demangle.so demangle.o -shared -defaultlib=libphobos2.so
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# d_demangler

A small utility to demange D symbols
19 changes: 19 additions & 0 deletions demangle.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import std.demangle : demangle;
import std.conv : to;
import std.string : toStringz;
import core.stdc.string : strncpy;

extern (C) int demangle_symbol(const(char)* c_name, char* buffer, int size)
{
const auto name = to!string(c_name);
auto demangled = demangle(name);

if (name == demangled) {
return 0;
}

const auto c_demangled = toStringz(demangled);
strncpy(buffer, c_demangled, size - 1);

return 1;
}

0 comments on commit e88abac

Please # to comment.