Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / Delphi [игнор отключен] [закрыт для гостей] / RTTI: reintroduce и final / 4 сообщений из 4, страница 1 из 1
30.04.2020, 15:36
    #39953313
kapas
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
RTTI: reintroduce и final
Оставляет ли компилятор какую-либо RTTI для методов о reintroduce и final? Если да, то как до нее добраться?
...
Рейтинг: 0 / 0
30.04.2020, 16:03
    #39953318
RTTI: reintroduce и final
Глянь в GetDeclaredMethods там вообще все методы, предков и так далее.

Я обычно, даже стандартные методы не использую. Используя свои типа

Код: pascal
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
function GetMethodsOnly(Base: TRttiType): TArray<TRttiMethod>;
type
  TArrArgsType = TArray<TRttiParameter>;
  TTTArrArgsType = TArray<TArrArgsType>;
  TArgsExistList = TDictionary<string, TTTArrArgsType>;
var
  Method: TRttiMethod;
  List: TArgsExistList;
  Name: string;
  Tmp: TTTArrArgsType;
  L, ListCurrent, ListMax: Integer;
  NewFor: Boolean;
  function IsParameterExist(P: TArrArgsType): Boolean;
  var
    T: TArrArgsType;
    I, Count: Integer;
  begin
    for T in Tmp do
    begin
      Count := Length(T);
      if Count = Length(P) then
      begin
        if Count = 0 then
          Exit(True);

        for I := 0 to Count - 1 do
          if T[I].ParamType <> P[I].ParamType then
            Exit(False);

        if I = Count then
          Exit(True);
      end;
    end;
    Exit(False);
  end;

begin
  ListCurrent := 0;
  ListMax := 100;
  SetLength(Result, ListMax);

  List := TArgsExistList.Create();
  while Base <> nil do
  begin
    NewFor := ListCurrent <= 0;
    for Method in Base.GetDeclaredMethods do
    begin
      SetLength(Tmp, 0); // free old step

      name := Method.Name.ToLower;

      if not NewFor and List.TryGetValue(name, Tmp) then
        if IsParameterExist(Method.GetParameters) then
          Continue;

      L := Length(Tmp);
      SetLength(Tmp, L + 1);

      Tmp[L] := Method.GetParameters;

      List.AddOrSetValue(name, Tmp);

      Result[ListCurrent] := Method;
      Inc(ListCurrent);

      if ListCurrent >= ListMax then
      begin
        Inc(ListMax, 100);
        SetLength(Result, ListMax);
      end;
    end;
    Base := Base.BaseType;
  end;

  List.Free;

  SetLength(Result, ListCurrent);
end;



А то как то непонятно что они возвращают, из первого из списка найденного
...
Рейтинг: 0 / 0
30.04.2020, 16:08
    #39953321
RTTI: reintroduce и final
Данная функция GetMethodsOnly возвращает именно методы нужного класса, без всяких предков. Но у предков берёт функционал, который не предоставляется от текущего класса к самому последнему.
...
Рейтинг: 0 / 0
30.04.2020, 16:49
    #39953338
kapas
Гость
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
RTTI: reintroduce и final
Копал уже в этом направлении... Увы, это не даст информации даже о overload и override.
...
Рейтинг: 0 / 0
Форумы / Delphi [игнор отключен] [закрыт для гостей] / RTTI: reintroduce и final / 4 сообщений из 4, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]