How to find a complex erroneous interface in Delphi (Win32)

I am trying to find some cryptic errors in the application and I think that some hard tricks on the interfaces may be the reason. Such castings are unsafe in Delphi, for example

ISomeInterface(CurrentObj)

which should be

CurrentObj as ISomeInterface

In light of the lack of compiler warnings that, in my opinion, should be emitted for hard throws, my question is how easy it is to find these casts in the code base? Perhaps something like a regular grep search? The code base is large, and you would always have to look for it manually.

+3
source share
2 answers

, . PCRE ( Perl ), , " " goofball Find IDE. grep, Perl, Ruby,.NET .

- :

\w+\s*\(

, , . :

TObject (Foo)

, , , , , :

TObject
  (Foo)

, , :

X := ISomeInterface // come back and look at this cast, it dangerous
  (CurrentObj);

.

, , - ​​ . .

Delphi, , , :

\b[TIE][A-Z]\w+\s*\(

, . , , T ( ) ( ) E ( Exception), , , . , , .

, , (, TfcTreeView, T), - Delphi (, , tobject(Foo) tobject(Foo)), . , , .

+6

, " ".

ITest\([^)]+\)

ITest -

+1

Source: https://habr.com/ru/post/1760420/


All Articles