Skip to content

Commit aba77d2

Browse files
QuillPushervgvassilev
authored andcommitted
Added Comments (Function Definitions) for CppInterOp Doxygen documentation
- Added Comments (Function Definitions) for CppInterOp Doxygen documentation - Incorporated minor changes in Interop.cpp and CppInterOp.h, as suggested in Vassil's review - changes to preamble section reverted - the "this pointer" term reverted - Made sentence openings consistent (e.g., Identifies > Checks) - Executed `git-clang-format` in CppInterOp.cpp and CppInterOp.h
1 parent 7c55174 commit aba77d2

File tree

2 files changed

+154
-17
lines changed

2 files changed

+154
-17
lines changed

include/clang/Interpreter/CppInterOp.h

Lines changed: 135 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ namespace Cpp {
6060
: m_Kind(K), m_GenericCall(C), m_FD(FD) {}
6161
JitCall(Kind K, DestructorCall C, TCppConstFunction_t Dtor)
6262
: m_Kind(K), m_DestructorCall(C), m_FD(Dtor) {}
63+
64+
/// Checks if the passed arguments are valid for the given function.
6365
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.
6469
void ReportInvokeStart(void* result, ArgList args, void* self) const;
6570
void ReportInvokeStart(void* object, unsigned long nary,
6671
int withFree) const;
@@ -79,10 +84,10 @@ namespace Cpp {
7984
/// Makes a call to a generic function or method.
8085
///\param[in] result - the location where the return result will be placed.
8186
///\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.
8388
// FIXME: Adjust the arguments and their types: args_size can be unsigned;
8489
// 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
8691
// decide to directly.
8792
void Invoke(void* result, ArgList args = {}, void* self = nullptr) const {
8893
// Forward if we intended to call a dtor with only 1 parameter.
@@ -122,179 +127,282 @@ namespace Cpp {
122127
///\returns true if the debugging printouts on stderr are enabled.
123128
bool IsDebugOutputEnabled();
124129

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.
126134
bool IsAggregate(TCppScope_t scope);
127135

136+
/// Checks if the scope is a namespace or not.
128137
bool IsNamespace(TCppScope_t scope);
129138

139+
/// Checks if the scope is a class or not.
130140
bool IsClass(TCppScope_t scope);
141+
131142
// See TClingClassInfo::IsLoaded
143+
/// Checks if the class definition is present, or not. Performs a
144+
/// template instantiation if necessary.
132145
bool IsComplete(TCppScope_t scope);
133146

134147
size_t SizeOf(TCppScope_t scope);
148+
149+
/// Checks if it is a "built-in" or a "complex" type.
135150
bool IsBuiltin(TCppType_t type);
136151

152+
/// Checks if it is a templated class.
137153
bool IsTemplate(TCppScope_t handle);
138154

155+
/// Checks if it is a class template specialization class.
139156
bool IsTemplateSpecialization(TCppScope_t handle);
140157

141158
bool IsAbstract(TCppType_t klass);
142159

160+
/// Checks if it is an enum name (EnumDecl represents an enum name).
143161
bool IsEnumScope(TCppScope_t handle);
144162

163+
/// Checks if it is an enum's value (EnumConstantDecl represents
164+
/// each enum constant that is defined).
145165
bool IsEnumConstant(TCppScope_t handle);
146166

167+
/// Checks if the passed value is an enum type or not.
147168
bool IsEnumType(TCppType_t type);
148169

149170
/// We assume that smart pointer types define both operator* and
150171
/// operator->.
151172
bool IsSmartPtrType(TCppType_t type);
152173

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.
153177
TCppType_t GetIntegerTypeFromEnumScope(TCppScope_t handle);
154178

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.
155182
TCppType_t GetIntegerTypeFromEnumType(TCppType_t handle);
156183

184+
/// Gets a list of all the enum constants for an enum.
157185
std::vector<TCppScope_t> GetEnumConstants(TCppScope_t scope);
158186

187+
/// Gets the enum name when an enum constant is passed.
159188
TCppType_t GetEnumConstantType(TCppScope_t scope);
160189

190+
/// Gets the index value (0,1,2, etcetera) of the enum constant
191+
/// that was passed into this function.
161192
TCppIndex_t GetEnumConstantValue(TCppScope_t scope);
162193

194+
/// Gets the size of the "type" that is passed in to this function.
163195
size_t GetSizeOfType(TCppType_t type);
164196

197+
/// Checks if the passed value is a variable.
165198
bool IsVariable(TCppScope_t scope);
166199

200+
/// Gets the name of any named decl (a class,
201+
/// namespace, variable, or a function).
167202
std::string GetName(TCppType_t klass);
168203

204+
/// This is similar to GetName() function, but besides
205+
/// the name, it also gets the template arguments.
169206
std::string GetCompleteName(TCppType_t klass);
170207

208+
/// Gets the "qualified" name (including the namespace) of any
209+
/// named decl (a class, namespace, variable, or a function).
171210
std::string GetQualifiedName(TCppType_t klass);
172211

212+
/// This is similar to GetQualifiedName() function, but besides
213+
/// the "qualified" name (including the namespace), it also
214+
/// gets the template arguments.
173215
std::string GetQualifiedCompleteName(TCppType_t klass);
174216

217+
/// Gets the list of namespaces utilized in the supplied scope.
175218
std::vector<TCppScope_t> GetUsingNamespaces(TCppScope_t scope);
176219

220+
/// Gets the global scope of the whole C++ instance.
177221
TCppScope_t GetGlobalScope();
178222

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.
179225
TCppScope_t GetScope(const std::string &name, TCppScope_t parent = 0);
180226

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.
181230
TCppScope_t GetScopeFromCompleteName(const std::string &name);
182231

232+
/// This function performs a lookup within the specified parent,
233+
/// a specific named entity (functions, enums, etcetera).
183234
TCppScope_t GetNamed(const std::string &name,
184235
TCppScope_t parent = nullptr);
185236

237+
/// Gets the parent of the scope that is passed as a parameter.
186238
TCppScope_t GetParentScope(TCppScope_t scope);
187239

240+
/// Gets the scope of the type that is passed as a parameter.
188241
TCppScope_t GetScopeFromType(TCppType_t type);
189242

243+
/// Gets the number of Base Classes for the Derived Class that
244+
/// is passed as a parameter.
190245
TCppIndex_t GetNumBases(TCppType_t klass);
191246

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.
192251
TCppScope_t GetBaseClass(TCppType_t klass, TCppIndex_t ibase);
193252

253+
/// Checks if the supplied Derived Class is a sub-class of the
254+
/// provided Base Class.
194255
bool IsSubclass(TCppScope_t derived, TCppScope_t base);
195256

257+
/// Each base has its own offset in a Derived Class. This offset can be
258+
/// used to get to the Base Class fields.
196259
int64_t GetBaseClassOffset(TCppScope_t derived, TCppScope_t base);
197260

261+
/// Gets a list of all the Methods that are in the Class that is
262+
/// supplied as a parameter.
198263
std::vector<TCppFunction_t> GetClassMethods(TCppScope_t klass);
199264

200265
///\returns if a class has a default constructor.
201266
bool HasDefaultConstructor(TCppScope_t scope);
202267

203-
///\returns the default constructor of a class if any.
268+
///\returns the default constructor of a class, if any.
204269
TCppFunction_t GetDefaultConstructor(TCppScope_t scope);
205270

206-
///\returns the class destructor.
271+
///\returns the class destructor, if any.
207272
TCppFunction_t GetDestructor(TCppScope_t scope);
208273

274+
/// Looks up all the functions that have the name that is
275+
/// passed as a parameter in this function.
209276
std::vector<TCppFunction_t> GetFunctionsUsingName(
210277
TCppScope_t scope, const std::string& name);
211278

279+
/// Gets the return type of the provided function.
212280
TCppType_t GetFunctionReturnType(TCppFunction_t func);
213281

282+
/// Gets the number of Arguments for the provided function.
214283
TCppIndex_t GetFunctionNumArgs(TCppFunction_t func);
215284

285+
/// Gets the number of Required Arguments for the provided function.
216286
TCppIndex_t GetFunctionRequiredArgs(TCppConstFunction_t func);
217287

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.
218291
TCppType_t GetFunctionArgType(TCppFunction_t func, TCppIndex_t iarg);
219292

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:
221294
/// void N::f(int i, double d, long l = 0, char ch = 'a').
222295
std::string GetFunctionSignature(TCppFunction_t func);
223296

224-
/// Returns if a function was marked as \c =delete.
297+
///\returns if a function was marked as \c =delete.
225298
bool IsFunctionDeleted(TCppConstFunction_t function);
226299

227300
bool IsTemplatedFunction(TCppFunction_t func);
228301

302+
/// This function performs a lookup to check if there is a
303+
/// templated function of that type.
229304
bool ExistsFunctionTemplate(const std::string& name,
230305
TCppScope_t parent = 0);
231306

307+
/// Checks if the provided parameter is a method.
232308
bool IsMethod(TCppConstFunction_t method);
233309

310+
/// Checks if the provided parameter is a 'Public' method.
234311
bool IsPublicMethod(TCppFunction_t method);
235312

313+
/// Checks if the provided parameter is a 'Protected' method.
236314
bool IsProtectedMethod(TCppFunction_t method);
237315

316+
/// Checks if the provided parameter is a 'Private' method.
238317
bool IsPrivateMethod(TCppFunction_t method);
239318

319+
/// Checks if the provided parameter is a Constructor.
240320
bool IsConstructor(TCppConstFunction_t method);
241321

322+
/// Checks if the provided parameter is a Destructor.
242323
bool IsDestructor(TCppConstFunction_t method);
243324

325+
/// Checks if the provided parameter is a 'Static' method.
244326
bool IsStaticMethod(TCppFunction_t method);
245327

328+
/// Gets the address of the function to be able to call it.
246329
TCppFuncAddr_t GetFunctionAddress(TCppFunction_t method);
247330

331+
/// Checks if the provided parameter is a 'Virtual' method.
248332
bool IsVirtualMethod(TCppFunction_t method);
249333

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.
250337
std::vector<TCppScope_t> GetDatamembers(TCppScope_t scope);
251338

339+
/// This is a Lookup function to be used specifically for data members.
252340
TCppScope_t LookupDatamember(const std::string& name, TCppScope_t parent);
253341

342+
/// Gets the type of the variable that is passed as a parameter.
254343
TCppType_t GetVariableType(TCppScope_t var);
255344

345+
/// Gets the address of the variable, you can use it to get the
346+
/// value stored in the variable.
256347
intptr_t GetVariableOffset(TCppScope_t var);
257348

349+
/// Checks if the provided variable is a 'Public' variable.
258350
bool IsPublicVariable(TCppScope_t var);
259351

352+
/// Checks if the provided variable is a 'Protected' variable.
260353
bool IsProtectedVariable(TCppScope_t var);
261354

355+
/// Checks if the provided variable is a 'Private' variable.
262356
bool IsPrivateVariable(TCppScope_t var);
263357

358+
/// Checks if the provided variable is a 'Static' variable.
264359
bool IsStaticVariable(TCppScope_t var);
265360

361+
/// Checks if the provided variable is a 'Constant' variable.
266362
bool IsConstVariable(TCppScope_t var);
267363

364+
/// Checks if the provided parameter is a Record (struct).
268365
bool IsRecordType(TCppType_t type);
269366

367+
/// Checks if the provided parameter is a Plain Old Data Type (POD).
270368
bool IsPODType(TCppType_t type);
271369

370+
/// Gets the pure, Underlying Type (as opposed to the Using Type).
272371
TCppType_t GetUnderlyingType(TCppType_t type);
273372

373+
/// Gets the Type (passed as a parameter) as a String value.
274374
std::string GetTypeAsString(TCppType_t type);
275375

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.
276379
TCppType_t GetCanonicalType(TCppType_t type);
277380

381+
/// Used to either get the built-in type of the provided string, or
382+
/// use the name to lookup the actual type.
278383
TCppType_t GetType(const std::string &type);
279384

385+
///\returns the complex of the provided type.
280386
TCppType_t GetComplexType(TCppType_t element_type);
281387

388+
/// This will convert a class into its type, so for example, you can
389+
/// use it to declare variables in it.
282390
TCppType_t GetTypeFromScope(TCppScope_t klass);
283391

284-
/// Check if a C++ type derives from another.
392+
/// Checks if a C++ type derives from another.
285393
bool IsTypeDerivedFrom(TCppType_t derived, TCppType_t base);
286394

287395
/// Creates a trampoline function by using the interpreter and returns a
288396
/// uniform interface to call it from compiled code.
289397
JitCall MakeFunctionCallable(TCppConstFunction_t func);
290398

291-
/// Checks if a function declared is of const type or not
399+
/// Checks if a function declared is of const type or not.
292400
bool IsConstMethod(TCppFunction_t method);
293401

294-
/// Returns the default argument value as string.
402+
///\returns the default argument value as string.
295403
std::string GetFunctionArgDefault(TCppFunction_t func, TCppIndex_t param_index);
296404

297-
/// Returns the argument name of function as string.
405+
///\returns the argument name of function as string.
298406
std::string GetFunctionArgName(TCppFunction_t func, TCppIndex_t param_index);
299407

300408
/// Creates an instance of the interpreter we need for the various interop
@@ -304,30 +412,42 @@ namespace Cpp {
304412
/// adds additional arguments to the interpreter.
305413
TInterp_t CreateInterpreter(const std::vector<const char *> &Args = {});
306414

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.
307418
///\returns the current interpreter instance, if any.
308419
TInterp_t GetInterpreter();
309420

421+
/// Adds a Search Path for the Interpreter to get the libraries.
310422
void AddSearchPath(const char *dir, bool isUser = true, bool prepend = false);
311423

312-
/// Returns the resource-dir path.
424+
/// Returns the resource-dir path (for headers).
313425
const char* GetResourceDir();
314426

427+
/// Secondary search path for headers, if not found using the
428+
/// GetResourceDir() function.
315429
void AddIncludePath(const char *dir);
316430

431+
/// Only Declares a code snippet in \c code and does not execute it.
317432
TCppIndex_t Declare(const char *code, bool silent = false);
318433

319-
/// Declares and runs a code snippet in \c code.
434+
/// Declares and executes a code snippet in \c code.
320435
///\returns 0 on success
321436
int Process(const char *code);
322437

323-
/// Declares, runs and returns the execution result as a intptr_t.
438+
/// Declares, executes and returns the execution result as a intptr_t.
324439
///\returns the expression results as a intptr_t.
325440
intptr_t Evaluate(const char *code, bool *HadError = nullptr);
326441

442+
/// Looks up the library if access is enabled.
443+
///\returns the path to the library.
327444
const std::string LookupLibrary(const char *lib_name);
328445

446+
/// Loads the library based on the path returned by the LookupLibrary()
447+
/// function.
329448
bool LoadLibrary(const char *lib_path, bool lookup = true);
330449

450+
/// Tries to load provided objects in a string format (prettyprint).
331451
std::string ObjToString(const char *type, void *obj);
332452

333453
struct TemplateArgInfo {
@@ -350,6 +470,7 @@ namespace Cpp {
350470
};
351471
}
352472

473+
/// Gets the size/dimensions of a multi-dimension array.
353474
std::vector<long int> GetDimensions(TCppType_t type);
354475

355476
/// Allocates memory for a given class.

0 commit comments

Comments
 (0)