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;
|
alias RT = FpcArray!T;
|
||||||
enum isChar = is(Unqual!T == char);
|
enum isChar = is(Unqual!T == char);
|
||||||
size_t len = size_t.sizeof * 2 + T.sizeof * array.length + ubyte(isChar);
|
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
|
// init refcount to -1 and length to izArray length
|
||||||
*cast(size_t*) (mem + 0 ) = -1;
|
*cast(size_t*) (mem + 0 ) = -1;
|
||||||
*cast(size_t*) (mem + size_t.sizeof) = array.length;
|
*cast(size_t*) (mem + size_t.sizeof) = array.length;
|
||||||
// copy izArray data
|
// 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.
|
// FreePascal specifies that strings are guaranteed to be zero terminated.
|
||||||
static if (isChar)
|
static if (isChar)
|
||||||
*cast(char*) (mem + len - 1) = '\0';
|
*cast(char*) (mem + len - 1) = '\0';
|
||||||
|
|
|
@ -3,11 +3,11 @@ module ddemangle;
|
||||||
import core.demangle : demangle;
|
import core.demangle : demangle;
|
||||||
import std.regex : replaceAll, Captures, regex, Regex;
|
import std.regex : replaceAll, Captures, regex, Regex;
|
||||||
import core.stdc.string : strlen;
|
import core.stdc.string : strlen;
|
||||||
import std.string : toStringz;
|
import common : FpcArray;
|
||||||
|
|
||||||
extern(C):
|
extern(C):
|
||||||
|
|
||||||
export const(char)* ddemangle(const(char)* line)
|
export FpcArray!(const(char))* ddemangle(const(char)* line)
|
||||||
{
|
{
|
||||||
__gshared Regex!char reDemangle;
|
__gshared Regex!char reDemangle;
|
||||||
__gshared bool reInit;
|
__gshared bool reInit;
|
||||||
|
@ -16,7 +16,9 @@ export const(char)* ddemangle(const(char)* line)
|
||||||
reInit = true;
|
reInit = true;
|
||||||
reDemangle = regex(r"\b_?_D[0-9a-zA-Z_]+\b");
|
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:
|
extern(D): private:
|
||||||
|
|
|
@ -24,7 +24,7 @@ begin
|
||||||
s := pchar(value);
|
s := pchar(value);
|
||||||
// note, assign to result has for effect to alloc a FPC string
|
// note, assign to result has for effect to alloc a FPC string
|
||||||
// (by implicit convertion) so the D memory is not used.
|
// (by implicit convertion) so the D memory is not used.
|
||||||
result := ddemangle(s);
|
result := string(ddemangle(s));
|
||||||
minimizeGcHeap();
|
minimizeGcHeap();
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -40,7 +40,7 @@ begin
|
||||||
begin
|
begin
|
||||||
value := values[i];
|
value := values[i];
|
||||||
if pos('_D', value) > 0 then
|
if pos('_D', value) > 0 then
|
||||||
value := demangle(PChar(value));
|
value := demangle(PChar(value));
|
||||||
output.AddStrings(value);
|
output.AddStrings(value);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
|
@ -62,7 +62,7 @@ procedure minimizeGcHeap(const now: boolean = false); cdecl; external libdexedd_
|
||||||
// noop
|
// noop
|
||||||
procedure setRtOptions(); cdecl; external libdexedd_name;
|
procedure setRtOptions(); cdecl; external libdexedd_name;
|
||||||
// Demangle a line possibly containing a D mangled 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.
|
// Detects wether the source code for the module `src` contains the main() function.
|
||||||
function hasMainFun(const src: PChar): Boolean; cdecl; external libdexedd_name;
|
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`.
|
// Returns the DDOC template for the declaration location at `caretLine` in the source code `src`.
|
||||||
|
|
Loading…
Reference in New Issue