rtti

Shrinking exe by removing RTTI

元气小坏坏 提交于 2019-12-21 02:44:19
问题 In this question (link) it was said that the line below (in each unit) would remove as much RTTI as possible: {$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])} The posting didn't mention what Delphi version it works with, but I assume D2010. However, when I include the line above, I get this error: DCC Fatal Error: E2158 System unit out of date or corrupted: missing TVisibilityClasses. I'm using a "stock" version of D2010 and have never done anything that I'm aware of that would change

Delphi 2010 RTTI : Explore Enumerations

空扰寡人 提交于 2019-12-20 12:08:36
问题 Considering such an enumeration : type TTypeOfData = ( [XmlName('ABC')] todABC, [XmlName('DEF')] todDEF, [XmlName('GHI')] todGHI ); Where XmlName is a custom attribute used to define the serialization string for members of this enumeration. How can I explore the attributes attached to each member of this enumeration ? 回答1: Attributes associated with elements in enumerations are not currently stored in Win32 RTTI data in the executable. RTTI is already responsible for a fair increase in the

C++ unique static id and class name with base class

人盡茶涼 提交于 2019-12-20 03:07:05
问题 Having class TaskBase , each derived class of it must have name and unique id. The TaskBase is something like below: class TaskBase { public: static const int id() { // return an unique id, for each object or derived class, HOW ?? } static const string name() { // return class name for each derived class, HOW ?? // for example : "TaskBase" for this class } }; My try was : template <typename DERIVED> class TaskBase { public: static const int id() { static const int id = reinterpret_cast<int>

Delphi: how to set the length of a RTTI-accessed dynamic array using DynArraySetLength?

让人想犯罪 __ 提交于 2019-12-20 01:47:26
问题 I'd like to set the length of a dynamic array, as suggested in this post. I have two classes TMyClass and the related TChildClass defined as TChildClass = class private FField1: string; FField2: string; end; TMyClass = class private FField1: TChildClass; FField2: Array of TChildClass; end; The array augmentation is implemented as var RContext: TRttiContext; RType: TRttiType; Val: TValue; // Contains the TMyClass instance RField: TRttiField; // A field in the TMyClass instance RElementType:

how to set array length with delphi 2010 rtti

你。 提交于 2019-12-19 23:19:33
问题 how to set array length in runtime ? setLength(t.GetProperty('Propertys'),3); ???? unit Unit3; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TSubProperty = Class private Fitem2: Integer; Fitem1: String; procedure Setitem1(const Value: String); procedure Setitem2(const Value: Integer); published property item1:String read Fitem1 write Setitem1; property item2:Integer read Fitem2 write Setitem2; End; TArraySubPropertys=array of

Can I ungarble GCC's RTTI names?

此生再无相见时 提交于 2019-12-19 07:23:44
问题 Using gcc, when I ask for an object/variable's type using typeid, I get a different result from the type_info::name method from what I'd expect to get on Windows. I Googled around a bit, and found out that RTTI names are implementation-specific. Problem is, I want to get a type's name as it would be returned on Windows. Is there an easy way to do this? 回答1: If it's what you're asking, there is no compiler switch that would make gcc behave like msvc regarding the name returned by type_info:

Delphi Rtti for interfaces in a generic context

天涯浪子 提交于 2019-12-18 16:51:02
问题 for a framework I wrote a wrapper which takes any object, interface or record type to explore its properties or fields. The class declaration is as follows: TWrapper<T> = class private FType : TRttiType; FInstance : Pointer; {...} public constructor Create (var Data : T); end; In the constructor I try to get the type information for further processing steps. constructor TWrapper<T>.Create (var Data : T); begin FType := RttiCtx.GetType (TypeInfo (T)); if FType.TypeKind = tkClass then FInstance

Why do I need to #include <typeinfo> when using the typeid operator?

北慕城南 提交于 2019-12-18 07:35:12
问题 The typeid represents a C++ RTTI operator being also a C++ keyword. It returns a std::type_info object that holds (dynamic) type specific information. From what I understood from various sources, one MUST include <typeinfo> when using typeid , otherwise the program is ill-formed. In fact, my gcc5.2 compiler doesn't even compile the program if I don't include the before-mentioned header. I don't understand why is a header inclusion mandated for the usage of a C++ keyword . I understand

RTTI Dynamic array TValue Delphi 2010

邮差的信 提交于 2019-12-18 02:59:37
问题 I have a question. I am a newbie with Run Time Type Information from Delphi 2010. I need to set length to a dynamic array into a TValue. You can see the code. Type TMyArray = array of integer; TMyClass = class publihed function Do:TMyArray; end; function TMyClass.Do:TMyArray; begin SetLength(Result,5); for i:=0 to 4 Result[i]=3; end; ....... ....... ...... y:TValue; Param:array of TValue; ......... y=Methods[i].Invoke(Obj,Param);//delphi give me a DynArray type kind, is working, Param works

How to typeof in C++

懵懂的女人 提交于 2019-12-17 19:51:41
问题 How to simulate C# typeof-command behavior in C++? C# example: public static PluginNodeList GetPlugins (Type type) { ... } Call: PluginManager.GetPlugins (typeof(IPlugin)) How to implement this using C++? Maybe QT or Boost libraries provide a solution? What about the case if you want to implement .GetPlugins(...) in a way that it loads those kinds of objects from a file (.so or .dll)? 回答1: You could use a dynamic_cast to test types as shown below: IPlugin* iPluginPtr = NULL; iPluginPtr =