mirror of https://gitlab.com/basile.b/dexed.git
ddemangle, use FPC compat string too
This commit is contained in:
parent
fe6f1db754
commit
4da5d1989e
|
@ -464,12 +464,12 @@ public:
|
|||
alias RT = FpcArray!T;
|
||||
enum isChar = is(Unqual!T == char);
|
||||
size_t len = size_t.sizeof * 2 + T.sizeof * array.length + ubyte(isChar);
|
||||
void* mem = getMem(len);
|
||||
auto mem = cast(Unqual!T*) getMem(len);
|
||||
// init refcount to -1 and length to izArray length
|
||||
*cast(size_t*) (mem + 0 ) = -1;
|
||||
*cast(size_t*) (mem + size_t.sizeof) = array.length;
|
||||
// copy izArray data
|
||||
mem[size_t.sizeof * 2 .. len - ubyte(isChar)] = array.ptr[0.. array.length * T.sizeof];
|
||||
mem[size_t.sizeof * 2 .. len - ubyte(isChar)] = (cast(T*) array.ptr)[0.. array.length * T.sizeof];
|
||||
// FreePascal specifies that strings are guaranteed to be zero terminated.
|
||||
static if (isChar)
|
||||
*cast(char*) (mem + len - 1) = '\0';
|
||||
|
|
|
@ -3,11 +3,11 @@ module ddemangle;
|
|||
import core.demangle : demangle;
|
||||
import std.regex : replaceAll, Captures, regex, Regex;
|
||||
import core.stdc.string : strlen;
|
||||
import std.string : toStringz;
|
||||
import common : FpcArray;
|
||||
|
||||
extern(C):
|
||||
|
||||
export const(char)* ddemangle(const(char)* line)
|
||||
export FpcArray!(const(char))* ddemangle(const(char)* line)
|
||||
{
|
||||
__gshared Regex!char reDemangle;
|
||||
__gshared bool reInit;
|
||||
|
@ -16,7 +16,9 @@ export const(char)* ddemangle(const(char)* line)
|
|||
reInit = true;
|
||||
reDemangle = regex(r"\b_?_D[0-9a-zA-Z_]+\b");
|
||||
}
|
||||
return replaceAll!(demangleMatch)(line[0 .. line.strlen], reDemangle).toStringz;
|
||||
return FpcArray!(const(char)).fromArray(
|
||||
replaceAll!(demangleMatch)(line[0 .. line.strlen], reDemangle)
|
||||
);
|
||||
}
|
||||
|
||||
extern(D): private:
|
||||
|
|
|
@ -24,7 +24,7 @@ begin
|
|||
s := pchar(value);
|
||||
// note, assign to result has for effect to alloc a FPC string
|
||||
// (by implicit convertion) so the D memory is not used.
|
||||
result := ddemangle(s);
|
||||
result := string(ddemangle(s));
|
||||
minimizeGcHeap();
|
||||
end
|
||||
else
|
||||
|
|
|
@ -62,7 +62,7 @@ procedure minimizeGcHeap(const now: boolean = false); cdecl; external libdexedd_
|
|||
// noop
|
||||
procedure setRtOptions(); cdecl; external libdexedd_name;
|
||||
// Demangle a line possibly containing a D mangled name.
|
||||
function ddemangle(const text: PChar): PChar; cdecl; external libdexedd_name;
|
||||
function ddemangle(const text: PChar): pointer; cdecl; external libdexedd_name;
|
||||
// Detects wether the source code for the module `src` contains the main() function.
|
||||
function hasMainFun(const src: PChar): Boolean; cdecl; external libdexedd_name;
|
||||
// Returns the DDOC template for the declaration location at `caretLine` in the source code `src`.
|
||||
|
|
Loading…
Reference in New Issue