|
|
|
Rtti Invoke
|
|||
|---|---|---|---|
|
#18+
Заметил баг, что при вызове TStyleManager.SetStyle он падает с raised exception class EInvalidCast with message 'Invalid class typecast'. Пример кода Код: 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. Ошибка просиходит тут Код: pascal 1. 2. 3. 4. 5. Этот баг фиксится ? ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.04.2018, 01:04 |
|
||
|
Rtti Invoke
|
|||
|---|---|---|---|
|
#18+
Падает с типом TStyleServicesHandle Код: pascal 1. По имени работает отлиычно. Но когда пытаешься загрузить по указателю на TMemoryStream то он падает ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.04.2018, 01:07 |
|
||
|
Rtti Invoke
|
|||
|---|---|---|---|
|
#18+
Наверно с родным твоерением - нереально баг обойти, только если свой инвок напишешь. Вот так к примеру как написал я Код: 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. И всё заработало ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.04.2018, 02:29 |
|
||
|
Rtti Invoke
|
|||
|---|---|---|---|
|
#18+
Вот инвок который поддерживает конструктор, в добавок теперь не надо следить за конвертированием адресса в TClass и TObject (Только надо следить за передаваемыми параметрами самому) Ну так как я уже конвертирую их из одного языка в другой, исходя из аргументов. То стандартный только двойную операцию делал, и не работал (Этот пока все тесты проходит ранние) Код: 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. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.04.2018, 03:37 |
|
||
|
Rtti Invoke
|
|||
|---|---|---|---|
|
#18+
Г.ы А вот целая функция, просто убрано конвертирование function MethodInvoke(Instance: pointer; m: TRttiMethod; Args: TArray<TValue>): TValue; type PPVtable = ^PVtable; PVtable = ^TVtable; TVtable = array [0 .. MaxInt div sizeof(pointer) - 1] of pointer; procedure PushSelfFirst(CC: TCallConv; var argList: TArray<TValue>; var Index: integer; const value: TValue); inline; begin {$IFDEF CPUX86} if CC = ccPascal then exit; {$ENDIF CPUX86} argList[Index] := value; inc(Index); end; procedure PushSelfLast(CC: TCallConv; var argList: TArray<TValue>; var Index: integer; const value: TValue); inline; begin {$IFDEF CPUX86} if CC <> ccPascal then exit; argList[Index] := value; {$ELSE !CPUX86} {$ENDIF CPUX86} end; var code: pointer; argCount: integer; parList: TArray<TRttiParameter>; i, CurrArg: integer; cls: TClass; obj: TObject; alloc: Boolean; plus, lARGS, gg, Min, Max: integer; P: TRttiParameter; v: TValue; begin with m do begin argCount := length(Args); gg := argCount; if IsConstructor or IsDestructor then inc(argCount); if not IsStatic then inc(argCount); SetLength(Args, argCount); lARGS := length(GetParameters); Max := argCount - 1; for Min := 0 to gg - 1 do begin v := Args[Min]; if (Min < lARGS) and v.IsEmpty then begin P := GetParameters[Min]; if P.ParamType.Handle <> nil then begin TValue.Make(nil, P.ParamType.Handle, v); end; end; Args[Min] := Args[Max]; Args[Max] := v; Dec(Max); end; CurrArg := 0; cls := nil; alloc := True; // avoid warning obj := nil; // avoid warning if not IsStatic then begin // Two jobs: handle special methods like ctor/dtor, and // extract metaclass so that vtable lookups can occur. if IsConstructor then begin alloc := TValue(Instance).TryAsType<TClass>(cls); // flag: should allocate if alloc then obj := nil // not used else begin obj := TValue(Instance).AsObject; if obj <> nil then cls := obj.ClassType else cls := nil; end; if alloc then PushSelfFirst(CallingConvention, Args, CurrArg, cls) else PushSelfFirst(CallingConvention, Args, CurrArg, obj); Args[CurrArg] := alloc; inc(CurrArg); end else if IsDestructor then begin cls := TValue(Instance).AsObject.ClassType; PushSelfFirst(CallingConvention, Args, CurrArg, Instance); Args[CurrArg] := True; inc(CurrArg); end else if IsClassMethod then begin cls := TValue(Instance).AsClass; PushSelfFirst(CallingConvention, Args, CurrArg, Instance); end else begin PushSelfFirst(CallingConvention, Args, CurrArg, Instance); end; end; if IsStatic then code := CodeAddress else case DispatchKind of dkVtable: code := PVtable(cls)^[VirtualIndex]; dkDynamic: code := GetDynaMethod(cls, VirtualIndex); else code := CodeAddress; end; if not IsStatic then begin if IsConstructor then begin if alloc then PushSelfLast(CallingConvention, Args, CurrArg, cls) else PushSelfLast(CallingConvention, Args, CurrArg, obj); end else PushSelfLast(CallingConvention, Args, CurrArg, Instance); end; if ReturnType <> nil then result := System.rtti.Invoke(code, Args, CallingConvention, ReturnType.Handle, IsStatic) else if IsConstructor then result := System.rtti.Invoke(code, Args, CallingConvention, cls.ClassInfo, IsStatic, True) else result := System.rtti.Invoke(code, Args, CallingConvention, nil); end; end; [SRC delphi][/SRC] ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.04.2018, 05:22 |
|
||
|
Rtti Invoke
|
|||
|---|---|---|---|
|
#18+
Код: 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. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102. 103. 104. 105. 106. 107. 108. 109. 110. 111. 112. 113. 114. 115. 116. 117. 118. 119. 120. 121. 122. 123. 124. 125. 126. 127. 128. 129. 130. 131. 132. 133. 134. 135. 136. 137. 138. 139. 140. 141. 142. 143. 144. 145. 146. 147. 148. 149. 150. 151. 152. 153. 154. 155. 156. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.04.2018, 05:22 |
|
||
|
|

start [/forum/topic.php?fid=58&gotonew=1&tid=2040967]: |
0ms |
get settings: |
8ms |
get forum list: |
14ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
140ms |
get topic data: |
8ms |
get first new msg: |
5ms |
get forum data: |
2ms |
get page messages: |
52ms |
get tp. blocked users: |
1ms |
| others: | 237ms |
| total: | 473ms |

| 0 / 0 |
