work on #39 for the linux platform

This commit is contained in:
Basile Burg 2015-09-16 02:49:53 +02:00
parent 375c96df01
commit 95fae8efbb
9 changed files with 32 additions and 21 deletions

View File

@ -13,6 +13,7 @@ object CurrentProject: TCENativeProject
debugingOptions.debug = True debugingOptions.debug = True
debugingOptions.codeviewDexts = True debugingOptions.codeviewDexts = True
messagesOptions.additionalWarnings = True messagesOptions.additionalWarnings = True
messagesOptions.tlsInformations = True
outputOptions.binaryKind = obj outputOptions.binaryKind = obj
pathsOptions.outputFilename = '../bin/cedast.o' pathsOptions.outputFilename = '../bin/cedast.o'
otherOptions.customOptions.Strings = ( otherOptions.customOptions.Strings = (
@ -30,7 +31,6 @@ object CurrentProject: TCENativeProject
) )
ConfigurationIndex = 1 ConfigurationIndex = 1
LibraryAliases.Strings = ( LibraryAliases.Strings = (
'libdparse' '*'
'iz'
) )
end end

View File

@ -1 +1 @@
dmd ../bin/cedast.o -of../bin/cedast.so -shared -defaultlib=libphobos2.so dmd ../bin/cedast.o /home/basile/Dev/dproj/Iz/lib/iz.a /home/basile/Dev/metad/libs/libdparse.a -of../bin/cedast.so -shared -defaultlib=libphobos2.so

View File

@ -1,7 +1,7 @@
module ast; module ast;
import std.d.lexer, std.d.parser, std.d.ast; import std.d.lexer, std.d.parser, std.d.ast;
import std.json, std.array, std.conv, std.parallelism; import std.json, std.array, std.conv, std.parallelism, std.concurrency;
import iz.enumset, iz.memory; import iz.enumset, iz.memory;
import common; import common;
@ -323,7 +323,7 @@ private:
ubyte[] todosJson; ubyte[] todosJson;
ubyte[] symsPas; ubyte[] symsPas;
ubyte[] symsJson; ubyte[] symsJson;
static AstError*[] errors; __gshared static AstError*[] errors;
final static void parserError(string fname, size_t line, size_t col, string msg, bool isErr) final static void parserError(string fname, size_t line, size_t col, string msg, bool isErr)
{ {
@ -349,6 +349,7 @@ private:
mod = parseModule(getTokensForParser(src, config, &strcache), fname, null, &parserError); mod = parseModule(getTokensForParser(src, config, &strcache), fname, null, &parserError);
if (notif) notif(notifparam); if (notif) notif(notifparam);
scanned = true; scanned = true;
} }
public: public:
@ -366,7 +367,8 @@ public:
try src = cast(ubyte[]) read(fname, size_t.max); try src = cast(ubyte[]) read(fname, size_t.max);
catch(Exception e){} catch(Exception e){}
scanned = false; scanned = false;
task(&taskScan).executeInNewThread; version(Windows)task(&taskScan).executeInNewThread;
else taskScan;
} }
final void scanBuffer(ubyte[] buffer) final void scanBuffer(ubyte[] buffer)
@ -374,7 +376,8 @@ public:
resetCachedInfo; resetCachedInfo;
src = buffer.dup; src = buffer.dup;
scanned = false; scanned = false;
task(&taskScan).executeInNewThread; version(Windows) task(&taskScan).executeInNewThread;
else taskScan;
} }
@property AstNotification notification(){return notif;} @property AstNotification notification(){return notif;}
@ -393,7 +396,7 @@ public:
foreach(Token t; mod.moduleDeclaration.moduleName.identifiers) foreach(Token t; mod.moduleDeclaration.moduleName.identifiers)
result ~= t.text ~ "."; result ~= t.text ~ ".";
if (result.length) if (result.length)
modName = result[0 .. $-1]; modName = result[0 .. $-1].idup;
} }
return modName; return modName;
} }
@ -421,7 +424,7 @@ public:
cachedInfos += AstInfos.SymsPas; cachedInfos += AstInfos.SymsPas;
SymbolListBuilder slb = construct!SymbolListBuilder(mod); SymbolListBuilder slb = construct!SymbolListBuilder(mod);
scope(exit) destruct(slb); scope(exit) destruct(slb);
symsPas = cast(ubyte[]) slb.serializePas(); symsPas = cast(ubyte[]) slb.serializePas().dup;
} }
return symsPas; return symsPas;
} }

View File

@ -4,11 +4,19 @@ import core.runtime, common, ast;
import iz.memory; import iz.memory;
__gshared Ast[] modules; __gshared Ast[] modules;
__gshared bool init;
void tryInit()
{
if (init) return;
Runtime.initialize;
init = true;
}
extern(C) export extern(C) export
AstHandle newAst(void* param, AstNotification clbck) AstHandle newAst(void* param, AstNotification clbck)
{ {
version(linux) tryInit;
AstHandle result; AstHandle result;
try try
{ {
@ -134,7 +142,7 @@ version(Windows)
final switch (ulReason) final switch (ulReason)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
Runtime.initialize; tryInit;
g_hInst = hInstance; g_hInst = hInstance;
dll_process_attach( hInstance, true ); dll_process_attach( hInstance, true );
break; break;
@ -155,4 +163,3 @@ version(Windows)
return true; return true;
} }
} }

View File

@ -1,8 +1,10 @@
module common; module common;
extern(C):
alias AstHandle = ptrdiff_t; alias AstHandle = ptrdiff_t;
alias AstNotification = extern(C) void function(void* param); alias AstNotification = void function(void* param);
__gshared immutable AstHandle invalidAstHandle = 0; __gshared immutable AstHandle invalidAstHandle = 0;

View File

@ -112,7 +112,6 @@
<RunParams> <RunParams>
<local> <local>
<FormatVersion Value="1"/> <FormatVersion Value="1"/>
<WorkingDirectory Value="C:\"/>
</local> </local>
</RunParams> </RunParams>
<RequiredPackages Count="6"> <RequiredPackages Count="6">

View File

@ -5,7 +5,7 @@ unit ce_dast;
interface interface
uses uses
dynlibs, forms; dynlibs, sysutils, ce_common;
type type
@ -44,14 +44,14 @@ var
implementation implementation
var var
dastHdl: TLibHandle; dastHdl: TLibHandle = 0;
fname: string;
initialization initialization
if application.GetOptionValue('cedast') = 'off' then fname := exeFullName('cedast' + dynExt);
exit; if FileExists(fname) then
dastHdl := LoadLibrary(fname);
dastHdl := LoadLibrary('cedast');
if dastHdl <> NilHandle then if dastHdl <> NilHandle then
begin begin
newAST := TNewAst(GetProcAddress(dastHdl, 'newAst')); newAST := TNewAst(GetProcAddress(dastHdl, 'newAst'));
@ -60,13 +60,11 @@ initialization
scanBuffer := TScanBuffer(GetProcAddress(dastHdl, 'scanBuffer')); scanBuffer := TScanBuffer(GetProcAddress(dastHdl, 'scanBuffer'));
moduleName := TModuleName(GetProcAddress(dastHdl, 'moduleName')); moduleName := TModuleName(GetProcAddress(dastHdl, 'moduleName'));
symbolList := TSymbolList(GetProcAddress(dastHdl, 'symbolList')); symbolList := TSymbolList(GetProcAddress(dastHdl, 'symbolList'));
symbolList := TSymbolList(GetProcAddress(dastHdl, 'symbolList'));
// //
dastAvailable := assigned(newAST) and assigned(deleteAST) and assigned(scanFile) dastAvailable := assigned(newAST) and assigned(deleteAST) and assigned(scanFile)
and assigned(scanBuffer) and assigned(moduleName) and assigned(symbolList); and assigned(scanBuffer) and assigned(moduleName) and assigned(symbolList);
end; end;
finalization finalization
{$IFDEF RELEASE} {$IFDEF RELEASE}
if dastHdl <> NilHandle then if dastHdl <> NilHandle then

View File

@ -712,6 +712,7 @@ begin
if fDoc.ast = 0 then exit; if fDoc.ast = 0 then exit;
// //
ptr := symbolList(fDoc.ast, len, TSerializationFormat.pas); ptr := symbolList(fDoc.ast, len, TSerializationFormat.pas);
if len = 0 then exit;
fSymStream.clear; fSymStream.clear;
fSymStream.Write(ptr^, len); fSymStream.Write(ptr^, len);
fSymStream.Position:=0; fSymStream.Position:=0;

View File

@ -377,6 +377,7 @@ begin
fAstTimer.Interval:= 2000; fAstTimer.Interval:= 2000;
fAstTimer.OnTimer:= @AstTimerEvent; fAstTimer.OnTimer:= @AstTimerEvent;
fAstTimer.Enabled:=true; fAstTimer.Enabled:=true;
fAstTimer.AutoEnabled:=true;
end; end;
// //
ShowHint := false; ShowHint := false;