@@ -60,7 +60,12 @@ namespace Cpp {
60
60
: m_Kind(K), m_GenericCall(C), m_FD(FD) {}
61
61
JitCall (Kind K, DestructorCall C, TCppConstFunction_t Dtor)
62
62
: m_Kind(K), m_DestructorCall(C), m_FD(Dtor) {}
63
+
64
+ // / Checks if the passed arguments are valid for the given function.
63
65
bool AreArgumentsValid (void * result, ArgList args, void * self) const ;
66
+
67
+ // / This function is used for debugging, it reports when the function was
68
+ // / called.
64
69
void ReportInvokeStart (void * result, ArgList args, void * self) const ;
65
70
void ReportInvokeStart (void * object, unsigned long nary,
66
71
int withFree) const ;
@@ -79,10 +84,10 @@ namespace Cpp {
79
84
// / Makes a call to a generic function or method.
80
85
// /\param[in] result - the location where the return result will be placed.
81
86
// /\param[in] args - a pointer to a argument list and argument size.
82
- // /\param[in] self - the this pointer of the object.
87
+ // /\param[in] self - the ' this pointer' of the object.
83
88
// FIXME: Adjust the arguments and their types: args_size can be unsigned;
84
89
// self can go in the end and be nullptr by default; result can be a nullptr
85
- // by default. These changes should be syncronized with the wrapper if we
90
+ // by default. These changes should be synchronized with the wrapper if we
86
91
// decide to directly.
87
92
void Invoke (void * result, ArgList args = {}, void * self = nullptr ) const {
88
93
// Forward if we intended to call a dtor with only 1 parameter.
@@ -122,179 +127,282 @@ namespace Cpp {
122
127
// /\returns true if the debugging printouts on stderr are enabled.
123
128
bool IsDebugOutputEnabled ();
124
129
125
- // /\returns true if the scope supports aggregate initialization.
130
+ // / Checks if the given class represents an aggregate type).
131
+ // /\returns true if \c scope is an array or a C++ tag (as per C++
132
+ // /[dcl.init.aggr]) \returns true if the scope supports aggregate
133
+ // / initialization.
126
134
bool IsAggregate (TCppScope_t scope);
127
135
136
+ // / Checks if the scope is a namespace or not.
128
137
bool IsNamespace (TCppScope_t scope);
129
138
139
+ // / Checks if the scope is a class or not.
130
140
bool IsClass (TCppScope_t scope);
141
+
131
142
// See TClingClassInfo::IsLoaded
143
+ // / Checks if the class definition is present, or not. Performs a
144
+ // / template instantiation if necessary.
132
145
bool IsComplete (TCppScope_t scope);
133
146
134
147
size_t SizeOf (TCppScope_t scope);
148
+
149
+ // / Checks if it is a "built-in" or a "complex" type.
135
150
bool IsBuiltin (TCppType_t type);
136
151
152
+ // / Checks if it is a templated class.
137
153
bool IsTemplate (TCppScope_t handle);
138
154
155
+ // / Checks if it is a class template specialization class.
139
156
bool IsTemplateSpecialization (TCppScope_t handle);
140
157
141
158
bool IsAbstract (TCppType_t klass);
142
159
160
+ // / Checks if it is an enum name (EnumDecl represents an enum name).
143
161
bool IsEnumScope (TCppScope_t handle);
144
162
163
+ // / Checks if it is an enum's value (EnumConstantDecl represents
164
+ // / each enum constant that is defined).
145
165
bool IsEnumConstant (TCppScope_t handle);
146
166
167
+ // / Checks if the passed value is an enum type or not.
147
168
bool IsEnumType (TCppType_t type);
148
169
149
170
// / We assume that smart pointer types define both operator* and
150
171
// / operator->.
151
172
bool IsSmartPtrType (TCppType_t type);
152
173
174
+ // / For the given "class", get the integer type that the enum
175
+ // / represents, so that you can store it properly in your specific
176
+ // / language.
153
177
TCppType_t GetIntegerTypeFromEnumScope (TCppScope_t handle);
154
178
179
+ // / For the given "type", this function gets the integer type that the enum
180
+ // / represents, so that you can store it properly in your specific
181
+ // / language.
155
182
TCppType_t GetIntegerTypeFromEnumType (TCppType_t handle);
156
183
184
+ // / Gets a list of all the enum constants for an enum.
157
185
std::vector<TCppScope_t> GetEnumConstants (TCppScope_t scope);
158
186
187
+ // / Gets the enum name when an enum constant is passed.
159
188
TCppType_t GetEnumConstantType (TCppScope_t scope);
160
189
190
+ // / Gets the index value (0,1,2, etcetera) of the enum constant
191
+ // / that was passed into this function.
161
192
TCppIndex_t GetEnumConstantValue (TCppScope_t scope);
162
193
194
+ // / Gets the size of the "type" that is passed in to this function.
163
195
size_t GetSizeOfType (TCppType_t type);
164
196
197
+ // / Checks if the passed value is a variable.
165
198
bool IsVariable (TCppScope_t scope);
166
199
200
+ // / Gets the name of any named decl (a class,
201
+ // / namespace, variable, or a function).
167
202
std::string GetName (TCppType_t klass);
168
203
204
+ // / This is similar to GetName() function, but besides
205
+ // / the name, it also gets the template arguments.
169
206
std::string GetCompleteName (TCppType_t klass);
170
207
208
+ // / Gets the "qualified" name (including the namespace) of any
209
+ // / named decl (a class, namespace, variable, or a function).
171
210
std::string GetQualifiedName (TCppType_t klass);
172
211
212
+ // / This is similar to GetQualifiedName() function, but besides
213
+ // / the "qualified" name (including the namespace), it also
214
+ // / gets the template arguments.
173
215
std::string GetQualifiedCompleteName (TCppType_t klass);
174
216
217
+ // / Gets the list of namespaces utilized in the supplied scope.
175
218
std::vector<TCppScope_t> GetUsingNamespaces (TCppScope_t scope);
176
219
220
+ // / Gets the global scope of the whole C++ instance.
177
221
TCppScope_t GetGlobalScope ();
178
222
223
+ // / Gets the namespace or class for the name passed as a parameter,
224
+ // / and if the parent is not passed, then global scope will be assumed.
179
225
TCppScope_t GetScope (const std::string &name, TCppScope_t parent = 0 );
180
226
227
+ // / When the namespace is known, then the parent doesn't need
228
+ // / to be specified. This will probably be phased-out in
229
+ // / future versions of the interop library.
181
230
TCppScope_t GetScopeFromCompleteName (const std::string &name);
182
231
232
+ // / This function performs a lookup within the specified parent,
233
+ // / a specific named entity (functions, enums, etcetera).
183
234
TCppScope_t GetNamed (const std::string &name,
184
235
TCppScope_t parent = nullptr );
185
236
237
+ // / Gets the parent of the scope that is passed as a parameter.
186
238
TCppScope_t GetParentScope (TCppScope_t scope);
187
239
240
+ // / Gets the scope of the type that is passed as a parameter.
188
241
TCppScope_t GetScopeFromType (TCppType_t type);
189
242
243
+ // / Gets the number of Base Classes for the Derived Class that
244
+ // / is passed as a parameter.
190
245
TCppIndex_t GetNumBases (TCppType_t klass);
191
246
247
+ // / Gets a specific Base Class using its index. Typically GetNumBases()
248
+ // / is used to get the number of Base Classes, and then that number
249
+ // / can be used to iterate through the index value to get each specific
250
+ // / base class.
192
251
TCppScope_t GetBaseClass (TCppType_t klass, TCppIndex_t ibase);
193
252
253
+ // / Checks if the supplied Derived Class is a sub-class of the
254
+ // / provided Base Class.
194
255
bool IsSubclass (TCppScope_t derived, TCppScope_t base);
195
256
257
+ // / Each base has its own offset in a Derived Class. This offset can be
258
+ // / used to get to the Base Class fields.
196
259
int64_t GetBaseClassOffset (TCppScope_t derived, TCppScope_t base);
197
260
261
+ // / Gets a list of all the Methods that are in the Class that is
262
+ // / supplied as a parameter.
198
263
std::vector<TCppFunction_t> GetClassMethods (TCppScope_t klass);
199
264
200
265
// /\returns if a class has a default constructor.
201
266
bool HasDefaultConstructor (TCppScope_t scope);
202
267
203
- // /\returns the default constructor of a class if any.
268
+ // /\returns the default constructor of a class, if any.
204
269
TCppFunction_t GetDefaultConstructor (TCppScope_t scope);
205
270
206
- // /\returns the class destructor.
271
+ // /\returns the class destructor, if any .
207
272
TCppFunction_t GetDestructor (TCppScope_t scope);
208
273
274
+ // / Looks up all the functions that have the name that is
275
+ // / passed as a parameter in this function.
209
276
std::vector<TCppFunction_t> GetFunctionsUsingName (
210
277
TCppScope_t scope, const std::string& name);
211
278
279
+ // / Gets the return type of the provided function.
212
280
TCppType_t GetFunctionReturnType (TCppFunction_t func);
213
281
282
+ // / Gets the number of Arguments for the provided function.
214
283
TCppIndex_t GetFunctionNumArgs (TCppFunction_t func);
215
284
285
+ // / Gets the number of Required Arguments for the provided function.
216
286
TCppIndex_t GetFunctionRequiredArgs (TCppConstFunction_t func);
217
287
288
+ // / For each Argument of a function, you can get the Argument Type
289
+ // / by providing the Argument Index, based on the number of arguments
290
+ // / from the GetFunctionNumArgs() function.
218
291
TCppType_t GetFunctionArgType (TCppFunction_t func, TCppIndex_t iarg);
219
292
220
- // / Returns a stringified version of a given function signature in the form:
293
+ // /\returns a stringified version of a given function signature in the form:
221
294
// / void N::f(int i, double d, long l = 0, char ch = 'a').
222
295
std::string GetFunctionSignature (TCppFunction_t func);
223
296
224
- // / Returns if a function was marked as \c =delete.
297
+ // /\returns if a function was marked as \c =delete.
225
298
bool IsFunctionDeleted (TCppConstFunction_t function);
226
299
227
300
bool IsTemplatedFunction (TCppFunction_t func);
228
301
302
+ // / This function performs a lookup to check if there is a
303
+ // / templated function of that type.
229
304
bool ExistsFunctionTemplate (const std::string& name,
230
305
TCppScope_t parent = 0 );
231
306
307
+ // / Checks if the provided parameter is a method.
232
308
bool IsMethod (TCppConstFunction_t method);
233
309
310
+ // / Checks if the provided parameter is a 'Public' method.
234
311
bool IsPublicMethod (TCppFunction_t method);
235
312
313
+ // / Checks if the provided parameter is a 'Protected' method.
236
314
bool IsProtectedMethod (TCppFunction_t method);
237
315
316
+ // / Checks if the provided parameter is a 'Private' method.
238
317
bool IsPrivateMethod (TCppFunction_t method);
239
318
319
+ // / Checks if the provided parameter is a Constructor.
240
320
bool IsConstructor (TCppConstFunction_t method);
241
321
322
+ // / Checks if the provided parameter is a Destructor.
242
323
bool IsDestructor (TCppConstFunction_t method);
243
324
325
+ // / Checks if the provided parameter is a 'Static' method.
244
326
bool IsStaticMethod (TCppFunction_t method);
245
327
328
+ // / Gets the address of the function to be able to call it.
246
329
TCppFuncAddr_t GetFunctionAddress (TCppFunction_t method);
247
330
331
+ // / Checks if the provided parameter is a 'Virtual' method.
248
332
bool IsVirtualMethod (TCppFunction_t method);
249
333
334
+ // / Gets all the Fields/Data Members of a Class. For now, it
335
+ // / only gets non-static data members but in a future update,
336
+ // / it may support getting static data members as well.
250
337
std::vector<TCppScope_t> GetDatamembers (TCppScope_t scope);
251
338
339
+ // / This is a Lookup function to be used specifically for data members.
252
340
TCppScope_t LookupDatamember (const std::string& name, TCppScope_t parent);
253
341
342
+ // / Gets the type of the variable that is passed as a parameter.
254
343
TCppType_t GetVariableType (TCppScope_t var);
255
344
345
+ // / Gets the address of the variable, you can use it to get the
346
+ // / value stored in the variable.
256
347
intptr_t GetVariableOffset (TCppScope_t var);
257
348
349
+ // / Checks if the provided variable is a 'Public' variable.
258
350
bool IsPublicVariable (TCppScope_t var);
259
351
352
+ // / Checks if the provided variable is a 'Protected' variable.
260
353
bool IsProtectedVariable (TCppScope_t var);
261
354
355
+ // / Checks if the provided variable is a 'Private' variable.
262
356
bool IsPrivateVariable (TCppScope_t var);
263
357
358
+ // / Checks if the provided variable is a 'Static' variable.
264
359
bool IsStaticVariable (TCppScope_t var);
265
360
361
+ // / Checks if the provided variable is a 'Constant' variable.
266
362
bool IsConstVariable (TCppScope_t var);
267
363
364
+ // / Checks if the provided parameter is a Record (struct).
268
365
bool IsRecordType (TCppType_t type);
269
366
367
+ // / Checks if the provided parameter is a Plain Old Data Type (POD).
270
368
bool IsPODType (TCppType_t type);
271
369
370
+ // / Gets the pure, Underlying Type (as opposed to the Using Type).
272
371
TCppType_t GetUnderlyingType (TCppType_t type);
273
372
373
+ // / Gets the Type (passed as a parameter) as a String value.
274
374
std::string GetTypeAsString (TCppType_t type);
275
375
376
+ // / Gets the Canonical Type string from the std string. A canonical type
377
+ // / is the type with any typedef names, syntactic sugars or modifiers stripped
378
+ // / out of it.
276
379
TCppType_t GetCanonicalType (TCppType_t type);
277
380
381
+ // / Used to either get the built-in type of the provided string, or
382
+ // / use the name to lookup the actual type.
278
383
TCppType_t GetType (const std::string &type);
279
384
385
+ // /\returns the complex of the provided type.
280
386
TCppType_t GetComplexType (TCppType_t element_type);
281
387
388
+ // / This will convert a class into its type, so for example, you can
389
+ // / use it to declare variables in it.
282
390
TCppType_t GetTypeFromScope (TCppScope_t klass);
283
391
284
- // / Check if a C++ type derives from another.
392
+ // / Checks if a C++ type derives from another.
285
393
bool IsTypeDerivedFrom (TCppType_t derived, TCppType_t base);
286
394
287
395
// / Creates a trampoline function by using the interpreter and returns a
288
396
// / uniform interface to call it from compiled code.
289
397
JitCall MakeFunctionCallable (TCppConstFunction_t func);
290
398
291
- // / Checks if a function declared is of const type or not
399
+ // / Checks if a function declared is of const type or not.
292
400
bool IsConstMethod (TCppFunction_t method);
293
401
294
- // / Returns the default argument value as string.
402
+ // /\returns the default argument value as string.
295
403
std::string GetFunctionArgDefault (TCppFunction_t func, TCppIndex_t param_index);
296
404
297
- // / Returns the argument name of function as string.
405
+ // /\returns the argument name of function as string.
298
406
std::string GetFunctionArgName (TCppFunction_t func, TCppIndex_t param_index);
299
407
300
408
// / Creates an instance of the interpreter we need for the various interop
@@ -304,30 +412,42 @@ namespace Cpp {
304
412
// / adds additional arguments to the interpreter.
305
413
TInterp_t CreateInterpreter (const std::vector<const char *> &Args = {});
306
414
415
+ // / Checks which Interpreter backend was CppInterOp library built with (Cling,
416
+ // / Clang-REPL, etcetera). In practice, the selected interpreter should not
417
+ // / matter, since the library will function in the same way.
307
418
// /\returns the current interpreter instance, if any.
308
419
TInterp_t GetInterpreter ();
309
420
421
+ // / Adds a Search Path for the Interpreter to get the libraries.
310
422
void AddSearchPath (const char *dir, bool isUser = true , bool prepend = false );
311
423
312
- // / Returns the resource-dir path.
424
+ // / Returns the resource-dir path (for headers) .
313
425
const char * GetResourceDir ();
314
426
427
+ // / Secondary search path for headers, if not found using the
428
+ // / GetResourceDir() function.
315
429
void AddIncludePath (const char *dir);
316
430
431
+ // / Only Declares a code snippet in \c code and does not execute it.
317
432
TCppIndex_t Declare (const char *code, bool silent = false );
318
433
319
- // / Declares and runs a code snippet in \c code.
434
+ // / Declares and executes a code snippet in \c code.
320
435
// /\returns 0 on success
321
436
int Process (const char *code);
322
437
323
- // / Declares, runs and returns the execution result as a intptr_t.
438
+ // / Declares, executes and returns the execution result as a intptr_t.
324
439
// /\returns the expression results as a intptr_t.
325
440
intptr_t Evaluate (const char *code, bool *HadError = nullptr );
326
441
442
+ // / Looks up the library if access is enabled.
443
+ // /\returns the path to the library.
327
444
const std::string LookupLibrary (const char *lib_name);
328
445
446
+ // / Loads the library based on the path returned by the LookupLibrary()
447
+ // / function.
329
448
bool LoadLibrary (const char *lib_path, bool lookup = true );
330
449
450
+ // / Tries to load provided objects in a string format (prettyprint).
331
451
std::string ObjToString (const char *type, void *obj);
332
452
333
453
struct TemplateArgInfo {
@@ -350,6 +470,7 @@ namespace Cpp {
350
470
};
351
471
}
352
472
473
+ // / Gets the size/dimensions of a multi-dimension array.
353
474
std::vector<long int > GetDimensions (TCppType_t type);
354
475
355
476
// / Allocates memory for a given class.
0 commit comments