Skip to content

Commit

Permalink
SyNode: revert commit what revert merged github pull request 122
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelmash committed Jul 24, 2018
1 parent ab6e3a9 commit a829828
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 10 deletions.
31 changes: 30 additions & 1 deletion SyNode/SpiderMonkey.pas
Expand Up @@ -486,7 +486,18 @@ interface
PJSStringFinalizer = ^JSStringFinalizer;

// jsid
jsid = size_t;
JSIdType = (
JSID_TYPE_STRING = $0,
JSID_TYPE_INT = $1,
JSID_TYPE_VOID = $2,
JSID_TYPE_SYMBOL = $4
);
jsid = record
asBits: size_t;
function isString: Boolean;
function asJSString: PJSString;
end;

TjsidVector = array[0..(MaxInt div sizeof(jsid))-2] of jsid;
PjsidVector = ^TjsidVector;

Expand Down Expand Up @@ -5029,6 +5040,24 @@ function JSArgRec.getThisObject(cx: PJSContext): PJSObject;
Result := this[cx].asObject;
end;

{ jsid }

const
JSID_TYPE_MASK = $7;

function jsid.isString: Boolean;
begin
Result := JSIdType(asBits and JSID_TYPE_MASK) = JSID_TYPE_STRING;
end;

function jsid.asJSString: PJSString;
begin
{$ifdef WITHASSERT}
Assert(isString);
{$endif}
Result := PJSString(asBits);
end;

{ JSIdArray }

procedure JSIdArray.init(cx: PJSContext);
Expand Down
20 changes: 11 additions & 9 deletions SyNode/SyNodeRemoteDebugger.pas
Expand Up @@ -438,6 +438,7 @@ procedure TSMRemoteDebuggerCommunicationThread.HandleMessage(const request: Vari
data: RawUTF8;
i: integer;
debuggerIndex: integer;
debugger: TSMDebugger;
Writer: TTextWriter;
engine: TSMEngine;
begin
Expand All @@ -449,32 +450,33 @@ procedure TSMRemoteDebuggerCommunicationThread.HandleMessage(const request: Vari
fParent.fDebuggers.Safe.Lock;
try
for I := 0 to fParent.fDebuggers.Count - 1 do begin
engine := fParent.fManager.EngineForThread(TSMDebugger(fParent.fDebuggers[i]).fSmThreadID);
debugger := TSMDebugger(fParent.fDebuggers[i]);
engine := fParent.fManager.EngineForThread(debugger.fSmThreadID);
if engine <> nil then begin
// Actor represent debug thread here, setting proper name with coxtext thread id
// Writer.AddShort('{"actor":"server1.conn1.addon');
// Writer.Add(TSMDebugger(fParent.fDebuggers[i]).fIndex);
Writer.AddShort('{"actor":"');
Writer.AddShort(TSMDebugger(fParent.fDebuggers[i]).fDebuggerName);
Writer.AddShort(debugger.fDebuggerName);
Writer.AddShort('.conn1.thread_');
{ TODO : check that in multithread mode this field equal thread id with js context that we debug, otherwire replace with proper assigment }
Writer.Add(TSMDebugger(fParent.fDebuggers[i]).fSmThreadID);
Writer.Add(debugger.fSmThreadID);
// id should be addon id, value from DoOnGetEngineName event
// Writer.AddShort('","id":"server1.conn1.addon');
// Writer.Add(TSMDebugger(fParent.fDebuggers[i]).fIndex);
Writer.AddShort('","id":"');
Writer.AddString(TSMDebugger(fParent.fDebuggers[i]).fNameForDebug);
Writer.AddString(debugger.fNameForDebug);
Writer.AddShort('","name":"');
Writer.AddString(TSMDebugger(fParent.fDebuggers[i]).fNameForDebug);
Writer.AddString(debugger.fNameForDebug);
// url most likly should be addon folder in format: file:///drive:/path/
// Writer.AddShort('","url":"server1.conn1.addon');
// Writer.Add(TSMDebugger(fParent.fDebuggers[i]).fIndex);
{ TODO : replace with path generation, should be context home dir in format file:///drive:/path/ }
Writer.AddShort('","url":"file:///' + StringReplaceAll(TSMDebugger(fParent.fDebuggers[i]).fWebAppRootPath, '\', '/'));
Writer.AddShort('","url":"file:///' + StringReplaceAll(debugger.fWebAppRootPath, '\', '/'));
Writer.AddShort('","debuggable":');
Writer.Add(TSMDebugger(fParent.fDebuggers[i]).fCommunicationThread = nil);
Writer.Add(debugger.fCommunicationThread = nil);
Writer.AddShort(',"consoleActor":"console');
Writer.Add(TSMDebugger(fParent.fDebuggers[i]).fIndex);
Writer.Add(debugger.fIndex);
Writer.AddShort('"},');
end;
end;
Expand Down Expand Up @@ -574,7 +576,7 @@ procedure TSMRemoteDebuggerCommunicationThread.sockWrite(const packet: RawUTF8);
fCommunicationSock.SockSend(@tmp[1], length(tmp));
fCommunicationSock.SockSend(@sep[1], length(sep));
fCommunicationSock.SockSend(@packet[1], length(packet));
fCommunicationSock.SockSendFlush;
fCommunicationSock.SockSendFlush('');
end;

procedure TSMRemoteDebuggerCommunicationThread.startListening(socket: TCrtSocket);
Expand Down

0 comments on commit a829828

Please sign in to comment.