浏览代码

* Merging revisions r46425 from trunk:
------------------------------------------------------------------------
r46425 | michael | 2020-08-14 12:33:07 +0200 (Fri, 14 Aug 2020) | 1 line

* Improved exception handling, patch by Henrique Werlang (bug ID 37567)
------------------------------------------------------------------------

git-svn-id: branches/fixes_3_2@46621 -

michael 5 年之前
父节点
当前提交
b2c215203e
共有 2 个文件被更改,包括 11 次插入14 次删除
  1. 1 9
      utils/pas2js/libstub.pp
  2. 10 5
      utils/pas2js/stubcreator.pp

+ 1 - 9
utils/pas2js/libstub.pp

@@ -123,15 +123,7 @@ end;
 Function ExecuteStubCreator(P : PStubCreator) : Boolean; stdcall;
 
 begin
-  Result:=False;
-  try
-    TStubCreator(P).Execute;
-    Result:=True;
-  except
-    On E: Exception do
-      Writeln('Exception ',E.ClassName,' ',E.Message);
-    // Ignore
-  end;
+  Result:=TStubCreator(P).Execute;
 end;
 
 Procedure GetStubCreatorLastError(P : PStubCreator; AError : PAnsiChar;

+ 10 - 5
utils/pas2js/stubcreator.pp

@@ -75,7 +75,7 @@ type
   Public
     Constructor Create(AOwner : TComponent); override;
     Destructor Destroy; override;
-    Procedure Execute;
+    Function Execute: Boolean;
     Procedure GetLastError(Out AError,AErrorClass : String);
     // Streams take precedence over filenames. They will be freed on destroy!
     // OutputStream can be used combined with write callbacks.
@@ -202,19 +202,22 @@ begin
     Include(O,woForwardClasses);
 end;
 
-procedure TStubCreator.Execute;
-
+function TStubCreator.Execute: Boolean;
 begin
   FLastErrorClass:='';
   FLastError:='';
+  Result := False;
+  if Defines.IndexOf('MakeStub')=-1 then
+
   Try
     DoExecute;
+
+    Result := True;
   except
     On E : Exception do
       begin
       FLastErrorClass:=E.Classname;
       FLastError:=E.Message;
-      Raise;
       end;
   end;
 end;
@@ -307,6 +310,8 @@ begin
     SCanner.OnLog:=SE.Onlog;
     For S in FDefines do
       Scanner.AddDefine(S);
+    if FDefines.IndexOf('MAKESTUB')=-1 then
+      Scanner.AddDefine('MAKESTUB');
     Scanner.OpenFile(InputFilename);
     // Parser
     Parser:=TPasParser.Create(Scanner, FileResolver, SE);
@@ -340,7 +345,7 @@ begin
   FLineNumberWidth:=4;
   FIndentSize:=2;
   FExtraUnits:='';
-  FOptions:=[woNoImplementation,woNoExternalClass,woNoExternalVar,woNoExternalFunc,woNoAsm,woSkipPrivateExternals,woAlwaysRecordHelper];
+  FOptions:=[woNoImplementation,woNoExternalClass,woNoExternalVar,woNoExternalFunc,woNoAsm,woSkipPrivateExternals,woAlwaysRecordHelper,woSkipHints];
 end;
 
 destructor TStubCreator.Destroy;