Panda3D
interrogate_interface.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file interrogate_interface.h
10 * @author frang
11 * @date 1999-11-09
12 */
13
14#ifndef INTERROGATE_INTERFACE_H
15#define INTERROGATE_INTERFACE_H
16
17#include "dtoolbase.h"
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23// This file defines the interface to the interrogate database. This database
24// is generated by running interrogate on a package's source code; interrogate
25// parses the C++ syntax, determines the public interface, generates C-style
26// wrapper functions where necessary, and builds up a table of functions and
27// classes and their relationships.
28
29/*
30 * Some of this data (in particular, the wrapper functions, and the table of
31 * unique names for these functions) is linked in along with the codebase,
32 * permanently a part of the library file, and is always available; the rest
33 * of it is stored in external files (named *.in) and read in when needed.
34 * For this reason, most of the interface functions defined here will force a
35 * load of the complete interrogate database the first time any of them are
36 * called. The three exceptions are noted below; they are
37 * interrogate_wrapper_has_pointer(), interrogate_wrapper_pointer(), and
38 * interrogate_get_wrapper_by_unique_name().
39 */
40
41
42// The interface here is intentionally made to be as simple as possible, to
43// maximize portability. All that is required of a scripting language is a
44// foreign function interface capable of calling C functions.
45
46
47// In general, the interrogate database consists of a number of query
48// functions that allow the caller to walk through the list of available
49// types, functions, manifests, etc. For each of these, a unique index number
50// is returned; this index number may then be used to query details about the
51// type, function, etc. The index numbers are only guaranteed to remain
52// unchanged during a particular session; from one session to another they may
53// differ.
54
55// All index numbers are ordinary integers. Each has a unique typedef here
56// for clarity of meaning, but they may be treated as ordinary integers by the
57// caller.
58typedef int ManifestIndex;
59typedef int ElementIndex;
60typedef int TypeIndex;
61typedef int FunctionIndex;
62typedef int FunctionWrapperIndex;
63typedef int MakeSeqIndex;
64
65// Atomic types are those that are built in to C. This enumerated value is
66// returned by interrogate_type_atomic_token() when a type is known to be one
67// of the atomic types.
68enum AtomicToken {
69 AT_not_atomic = 0,
70 AT_int = 1,
71 AT_float = 2,
72 AT_double = 3,
73 AT_bool = 4,
74 AT_char = 5,
75 AT_void = 6,
76
77 // There isn't an atomic string type in C, but there is one in almost all
78 // other languages. If -string is supplied to the interrogate command line,
79 // functions may be reported as returning and accepting objects of type
80 // atomic string. For the C calling convention wrappers, atomic string
81 // means (const char *); for other calling convention wrappers, atomic
82 // string means whatever the native string representation is.
83 AT_string = 7,
84
85 AT_longlong = 8,
86
87 // This is not a type that C has, but C++ and many scripting languages do;
88 // it indicates a null value, or the absence of any value.
89 AT_null = 9,
90};
91
92EXPCL_INTERROGATEDB void interrogate_add_search_directory(const char *dirname);
93EXPCL_INTERROGATEDB void interrogate_add_search_path(const char *pathstring);
94EXPCL_INTERROGATEDB bool interrogate_error_flag();
95
96// Manifest Symbols
97
98/*
99 * These correspond to #define constants that appear in the C code. (These
100 * are only the manifest constants--those #define's that take no parameters.
101 * Manifest functions, #define's that take one or more parameters, are not
102 * exported.) They cannot be set, of course, but they often have a meaningful
103 * value that may be get. The scripting language may choose to get the value
104 * as a literal string via interrogate_manifest_definition(), or as a value of
105 * a particular type (whatever type interrogate thinks it is), as returned by
106 * the getter function given by interrogate_manifest_getter().
107 */
108
109EXPCL_INTERROGATEDB int interrogate_number_of_manifests();
110EXPCL_INTERROGATEDB ManifestIndex interrogate_get_manifest(int n);
111EXPCL_INTERROGATEDB ManifestIndex interrogate_get_manifest_by_name(const char *manifest_name);
112EXPCL_INTERROGATEDB const char *interrogate_manifest_name(ManifestIndex manifest);
113EXPCL_INTERROGATEDB const char *interrogate_manifest_definition(ManifestIndex manifest);
114EXPCL_INTERROGATEDB bool interrogate_manifest_has_type(ManifestIndex manifest);
115EXPCL_INTERROGATEDB TypeIndex interrogate_manifest_get_type(ManifestIndex manifest);
116EXPCL_INTERROGATEDB bool interrogate_manifest_has_getter(ManifestIndex manifest);
117EXPCL_INTERROGATEDB FunctionIndex interrogate_manifest_getter(ManifestIndex manifest);
118
119// An exception is made for manifest constants that have an integer type
120// value, since these are so common. The scripting language can query these
121// values directly, which saves having to generate a wrapper function for each
122// stupid little manifest. In this case, there will be no getter function
123// available.
124EXPCL_INTERROGATEDB bool interrogate_manifest_has_int_value(ManifestIndex manifest);
125EXPCL_INTERROGATEDB int interrogate_manifest_get_int_value(ManifestIndex manifest);
126
127
128// Data Elements
129
130// These correspond to data members of a class, or global data elements.
131// Interrogate automatically generates a getter function and, if possible, a
132// setter function.
133
134EXPCL_INTERROGATEDB const char *interrogate_element_name(ElementIndex element);
135EXPCL_INTERROGATEDB const char *interrogate_element_scoped_name(ElementIndex element);
136EXPCL_INTERROGATEDB bool interrogate_element_has_comment(ElementIndex element);
137EXPCL_INTERROGATEDB const char *interrogate_element_comment(ElementIndex element);
138EXPCL_INTERROGATEDB ElementIndex interrogate_get_element_by_name(const char *element_name);
139EXPCL_INTERROGATEDB ElementIndex interrogate_get_element_by_scoped_name(const char *element_name);
140
141// Be careful with this function. The element's bare type is not likely to be
142// directly useful to the scripting language. This is a different answer than
143// the return value of the getter.
144
145// The element type might well be something concrete that the scripting
146// language can't handle directly, e.g. a Node, while the getter will return
147// (and the setter accept) a pointer to a Node, which is what the scripting
148// language actually works with.
149EXPCL_INTERROGATEDB TypeIndex interrogate_element_type(ElementIndex element);
150
151EXPCL_INTERROGATEDB bool interrogate_element_has_getter(ElementIndex element);
152EXPCL_INTERROGATEDB FunctionIndex interrogate_element_getter(ElementIndex element);
153EXPCL_INTERROGATEDB bool interrogate_element_has_setter(ElementIndex element);
154EXPCL_INTERROGATEDB FunctionIndex interrogate_element_setter(ElementIndex element);
155
156EXPCL_INTERROGATEDB bool interrogate_element_is_sequence(ElementIndex element);
157EXPCL_INTERROGATEDB bool interrogate_element_is_mapping(ElementIndex element);
158
159// Global Data
160
161// This is the list of global data elements.
162
163EXPCL_INTERROGATEDB int interrogate_number_of_globals();
164EXPCL_INTERROGATEDB ElementIndex interrogate_get_global(int n);
165
166// Functions
167
168// There is a unique FunctionIndex associated with each of the functions that
169// interrogate knows about. This includes member functions, nonmember
170// functions, synthesized getters and setters, and upcastdowncast functions.
171
172
173// These are the global (nonmember) functions that appear outside of any class
174// definition.
175EXPCL_INTERROGATEDB int interrogate_number_of_global_functions();
176EXPCL_INTERROGATEDB FunctionIndex interrogate_get_global_function(int n);
177
178// This can be used to traverse through *all* the functions known to
179// interrogate. It's usually not what you want, since this includes global
180// functions, class methods, and synthesized functions like upcasts and
181// downcasts. You probably want to use instead
182// interrogate_number_of_global_functions(), above.
183EXPCL_INTERROGATEDB int interrogate_number_of_functions();
184EXPCL_INTERROGATEDB FunctionIndex interrogate_get_function(int n);
185
186// This is the function's name. It is not unique; it may be shared between
187// multiple different functions that have the same name but different
188// parameter types (this is C++'s function overloading). Two different classes
189// might also have member functions that have the same name, or the same name
190// as a global function (but also see the scoped_name, below).
191EXPCL_INTERROGATEDB const char *interrogate_function_name(FunctionIndex function);
192
193// The scoped name is the function name prefixed with the name of the class
194// that includes the function, if the function is a class method. If it is a
195// global function, the scoped name is the same as the name returned above.
196// In the absence of C++ function overloading, this name will be unique to
197// each function.
198EXPCL_INTERROGATEDB const char *interrogate_function_scoped_name(FunctionIndex function);
199
200// This returns the C++ comment written for the function, either in the header
201// file or in the .C file, or both.
202EXPCL_INTERROGATEDB bool interrogate_function_has_comment(FunctionIndex function);
203EXPCL_INTERROGATEDB const char *interrogate_function_comment(FunctionIndex function);
204
205// This defines the function prototype as it appears in the C++ source, useful
206// primarily for documentation purposes.
207EXPCL_INTERROGATEDB const char *interrogate_function_prototype(FunctionIndex function);
208
209// This can be used to determine the class that the function is a method for,
210// if the function is a class method.
211EXPCL_INTERROGATEDB bool interrogate_function_is_method(FunctionIndex function);
212EXPCL_INTERROGATEDB TypeIndex interrogate_function_class(FunctionIndex function);
213
214// This returns the module name reported for the function, if available.
215EXPCL_INTERROGATEDB bool interrogate_function_has_module_name(FunctionIndex function);
216EXPCL_INTERROGATEDB const char *interrogate_function_module_name(FunctionIndex function);
217
218// This returns the library name reported for the function, if available.
219EXPCL_INTERROGATEDB bool interrogate_function_has_library_name(FunctionIndex function);
220EXPCL_INTERROGATEDB const char *interrogate_function_library_name(FunctionIndex function);
221
222// This is true for virtual member functions. It's not likely that this will
223// be important to the scripting language.
224EXPCL_INTERROGATEDB bool interrogate_function_is_virtual(FunctionIndex function);
225
226
227// The actual callable function interface is defined via one or more wrappers
228// for each function. (There might be multiple wrappers for the same function
229// to allow for default parameter values.)
230
231// At present, interrogate can generate wrappers that use the C calling
232// convention or the Python calling convention. The set of wrappers that will
233// actually be available depends on the parameters passed to the interrogate
234// command line.
235EXPCL_INTERROGATEDB int interrogate_function_number_of_c_wrappers(FunctionIndex function);
236EXPCL_INTERROGATEDB FunctionWrapperIndex interrogate_function_c_wrapper(FunctionIndex function, int n);
237
238EXPCL_INTERROGATEDB int interrogate_function_number_of_python_wrappers(FunctionIndex function);
239EXPCL_INTERROGATEDB FunctionWrapperIndex interrogate_function_python_wrapper(FunctionIndex function, int n);
240
241// Function wrappers
242
243// These define the way to call a given function. Depending on the parameters
244// supplied to interrogate, a function wrapper may be able to supply either a
245// void * pointer to the function, or the name of the function in the library,
246// or both.
247
248
249// This returns the actual name of the wrapper function, as opposed to the
250// name of the function it wraps. It's probably not terribly useful to the
251// scripting language, unless the -fnames option was given to interrogate, in
252// which case this name may be used to call the wrapper function (see
253// is_callable_by_name, below). It will usually be an ugly hashed name, not
254// intended for human consumption.
255
256// Don't confuse this with the unique_name, below. The two are related, but
257// not identical.
258EXPCL_INTERROGATEDB const char *interrogate_wrapper_name(FunctionWrapperIndex wrapper);
259
260// This returns true if -fnames was given to interrogate, making the wrapper
261// function callable directly by its name.
262EXPCL_INTERROGATEDB bool interrogate_wrapper_is_callable_by_name(FunctionWrapperIndex wrapper);
263
264// This returns the C++ comment written for the function wrapper, usually from
265// the .cpp file. There may be a different comment for each overload of a
266// given function.
267EXPCL_INTERROGATEDB bool interrogate_wrapper_has_comment(FunctionWrapperIndex wrapper);
268EXPCL_INTERROGATEDB const char *interrogate_wrapper_comment(FunctionWrapperIndex wrapper);
269
270// Every function wrapper has zero or more parameters and may or may not have
271// a return value. Each parameter has a type and may or may not have a name.
272// For member functions, the first parameter may be a 'this' parameter, which
273// should receive a pointer to the class object. (If a member function does
274// not have a 'this' parameter as its first parameter, it is a static member
275// function, also called a class method.)
276
277EXPCL_INTERROGATEDB bool interrogate_wrapper_has_return_value(FunctionWrapperIndex wrapper);
278EXPCL_INTERROGATEDB TypeIndex interrogate_wrapper_return_type(FunctionWrapperIndex wrapper);
279
280/*
281 * Sometimes interrogate must synthesize a wrapper that allocates its return
282 * value from the free store. Other times (especially if -refcount is
283 * supplied to interrogate), interrogate will automatically increment the
284 * count of a reference-counted object that it returns. In cases like these,
285 * interrogate_wrapper_caller_manages_return_value() will return true, and it
286 * is the responsibility of the scripting language to eventually call the
287 * destructor supplied by interrogate_wrapper_return_value_destructor() on
288 * this value when it is no longer needed (which will generally be the same
289 * destructor as that for the class). Otherwise, this function will return
290 * false, and the scripting language should *not* call any destructor on this
291 * value.
292 */
293EXPCL_INTERROGATEDB bool interrogate_wrapper_caller_manages_return_value(FunctionWrapperIndex wrapper);
294EXPCL_INTERROGATEDB FunctionIndex interrogate_wrapper_return_value_destructor(FunctionWrapperIndex wrapper);
295
296// These define the parameters of the function.
297EXPCL_INTERROGATEDB int interrogate_wrapper_number_of_parameters(FunctionWrapperIndex wrapper);
298EXPCL_INTERROGATEDB TypeIndex interrogate_wrapper_parameter_type(FunctionWrapperIndex wrapper, int n);
299EXPCL_INTERROGATEDB bool interrogate_wrapper_parameter_has_name(FunctionWrapperIndex wrapper, int n);
300EXPCL_INTERROGATEDB const char *interrogate_wrapper_parameter_name(FunctionWrapperIndex wrapper, int n);
301EXPCL_INTERROGATEDB bool interrogate_wrapper_parameter_is_this(FunctionWrapperIndex wrapper, int n);
302
303// This returns a pointer to a function that may be called to invoke the
304// function, if the -fptrs option to return function pointers was specified to
305// interrogate. Be sure to push the required parameters on the stack,
306// according to the calling convention, before calling the function.
307
308// These two functions may be called without forcing a load of the complete
309// interrogate database.
310EXPCL_INTERROGATEDB bool interrogate_wrapper_has_pointer(FunctionWrapperIndex wrapper);
311EXPCL_INTERROGATEDB void *interrogate_wrapper_pointer(FunctionWrapperIndex wrapper);
312
313// This function will return a name that is guaranteed to be unique to this
314// particular function wrapper, and that will (usually) be consistent across
315// multiple runtime sessions. (It will only change between sessions if the
316// database was regenerated in the interim with some new function that
317// happened to introduce a hash conflict.)
318
319// The unique name is an ugly hashed name, not safe for human consumption.
320// Its sole purpose is to provide some consistent way to identify function
321// wrappers between sessions.
322EXPCL_INTERROGATEDB const char *interrogate_wrapper_unique_name(FunctionWrapperIndex wrapper);
323
324// This function provides a reverse-lookup on the above unique name, returning
325// the wrapper index corresponding to the given name. It depends on data
326// having been compiled directly into the library, and thus is only available
327// if the option -unique-names was given to interrogate.
328
329// This function may be called without forcing a load of the complete
330// interrogate database.
331EXPCL_INTERROGATEDB FunctionWrapperIndex interrogate_get_wrapper_by_unique_name(const char *unique_name);
332
333// MakeSeqs
334
335// These are special synthesized methods that iterate through a list. They
336// are generated in C++ code via the MAKE_SEQ macro. The normal pattern is
337// that a pair of actual C++ methods like get_num_things() and get_thing(n)
338// are used to synthesize a new method called get_things().
339
340EXPCL_INTERROGATEDB const char *interrogate_make_seq_seq_name(MakeSeqIndex make_seq);
341EXPCL_INTERROGATEDB const char *interrogate_make_seq_scoped_name(MakeSeqIndex make_seq);
342EXPCL_INTERROGATEDB bool interrogate_make_seq_has_comment(ElementIndex element);
343EXPCL_INTERROGATEDB const char *interrogate_make_seq_comment(ElementIndex element);
344// The name of the real method that returns the length, e.g. "get_num_things"
345EXPCL_INTERROGATEDB const char *interrogate_make_seq_num_name(MakeSeqIndex make_seq);
346// The name of the real method that returns the nth element, e.g. "get_thing"
347EXPCL_INTERROGATEDB const char *interrogate_make_seq_element_name(MakeSeqIndex make_seq);
348
349
350// Types
351
352// These are all the types that interrogate knows about. This includes atomic
353// types like ints and floats, type wrappers like pointers and const pointers,
354// enumerated types, and classes.
355
356/*
357 * Two lists of types are maintained: the list of global types, which includes
358 * only those types intended to be wrapped in the API (for instance, all of
359 * the classes). The second list is the complete list of all types, which
360 * probably does not need to be traversed--this includes *all* types known to
361 * the interrogate database, including simple types and pointers and const
362 * pointers to classes. These types are necessary to fully define all of the
363 * function parameters, but need not themselves be wrapped.
364 */
365
366EXPCL_INTERROGATEDB int interrogate_number_of_global_types();
367EXPCL_INTERROGATEDB TypeIndex interrogate_get_global_type(int n);
368EXPCL_INTERROGATEDB int interrogate_number_of_types();
369EXPCL_INTERROGATEDB TypeIndex interrogate_get_type(int n);
370EXPCL_INTERROGATEDB TypeIndex interrogate_get_type_by_name(const char *type_name);
371EXPCL_INTERROGATEDB TypeIndex interrogate_get_type_by_scoped_name(const char *type_name);
372EXPCL_INTERROGATEDB TypeIndex interrogate_get_type_by_true_name(const char *type_name);
373EXPCL_INTERROGATEDB bool interrogate_type_is_global(TypeIndex type);
374EXPCL_INTERROGATEDB const char *interrogate_type_name(TypeIndex type);
375EXPCL_INTERROGATEDB const char *interrogate_type_scoped_name(TypeIndex type);
376EXPCL_INTERROGATEDB const char *interrogate_type_true_name(TypeIndex type);
377
378// A given type might be a nested type, meaning it is entirely defined within
379// (and scoped within) some different C++ class. In this case, the
380// type_name() will return the local name of the type as seen within the
381// class, while the scoped_name() will return the fully-qualified name of the
382// type, and is_nested() and outer_class() can be used to determine the class
383// it is nested within.
384EXPCL_INTERROGATEDB bool interrogate_type_is_nested(TypeIndex type);
385EXPCL_INTERROGATEDB TypeIndex interrogate_type_outer_class(TypeIndex type);
386
387EXPCL_INTERROGATEDB bool interrogate_type_has_comment(TypeIndex type);
388EXPCL_INTERROGATEDB const char *interrogate_type_comment(TypeIndex type);
389
390// This returns the module name reported for the type, if available.
391EXPCL_INTERROGATEDB bool interrogate_type_has_module_name(TypeIndex type);
392EXPCL_INTERROGATEDB const char *interrogate_type_module_name(TypeIndex type);
393
394// This returns the library name reported for the type, if available.
395EXPCL_INTERROGATEDB bool interrogate_type_has_library_name(TypeIndex type);
396EXPCL_INTERROGATEDB const char *interrogate_type_library_name(TypeIndex type);
397
398
399// If interrogate_type_is_atomic() returns true, the type is one of the basic
400// C types enumerated in AtomicToken, above. The type may then be further
401// modified by one or more of unsigned, signed, long, longlong, or short.
402// However, it will not be a pointer.
403EXPCL_INTERROGATEDB bool interrogate_type_is_atomic(TypeIndex type);
404EXPCL_INTERROGATEDB AtomicToken interrogate_type_atomic_token(TypeIndex type);
405EXPCL_INTERROGATEDB bool interrogate_type_is_unsigned(TypeIndex type);
406EXPCL_INTERROGATEDB bool interrogate_type_is_signed(TypeIndex type);
407EXPCL_INTERROGATEDB bool interrogate_type_is_long(TypeIndex type);
408EXPCL_INTERROGATEDB bool interrogate_type_is_longlong(TypeIndex type);
409EXPCL_INTERROGATEDB bool interrogate_type_is_short(TypeIndex type);
410
411// If interrogate_type_is_wrapped() returns true, this is a composite type
412// "wrapped" around some simpler type, for instance a pointer to a class. The
413// type will be either a pointer or a const wrapper--it cannot be a
414// combination of these. (When combinations are required, they use multiple
415// wrappers. A const char pointer, for example, is represented as a pointer
416// wrapper around a const wrapper around an atomic char.)
417EXPCL_INTERROGATEDB bool interrogate_type_is_wrapped(TypeIndex type);
418EXPCL_INTERROGATEDB bool interrogate_type_is_pointer(TypeIndex type);
419EXPCL_INTERROGATEDB bool interrogate_type_is_const(TypeIndex type);
420EXPCL_INTERROGATEDB bool interrogate_type_is_typedef(TypeIndex type);
421EXPCL_INTERROGATEDB TypeIndex interrogate_type_wrapped_type(TypeIndex type);
422
423// If interrogate_type_is_enum() returns true, this is an enumerated type,
424// which means it may take any one of a number of named integer values.
425EXPCL_INTERROGATEDB bool interrogate_type_is_enum(TypeIndex type);
426EXPCL_INTERROGATEDB int interrogate_type_number_of_enum_values(TypeIndex type);
427EXPCL_INTERROGATEDB const char *interrogate_type_enum_value_name(TypeIndex type, int n);
428EXPCL_INTERROGATEDB const char *interrogate_type_enum_value_scoped_name(TypeIndex type, int n);
429EXPCL_INTERROGATEDB const char *interrogate_type_enum_value_comment(TypeIndex type, int n);
430EXPCL_INTERROGATEDB int interrogate_type_enum_value(TypeIndex type, int n);
431
432// If none of the above is true, the type is some extension type. It may be a
433// struct, class, or union (and the distinction between these three is not
434// likely to be important to the scripting language). In any case, it may
435// contain zero or more constructors, zero or one destructor, zero or more
436// member functions, and zero or more data members; all of the remaining type
437// functions may apply.
438EXPCL_INTERROGATEDB bool interrogate_type_is_struct(TypeIndex type);
439EXPCL_INTERROGATEDB bool interrogate_type_is_class(TypeIndex type);
440EXPCL_INTERROGATEDB bool interrogate_type_is_union(TypeIndex type);
441
442// If is_fully_defined() returns false, this classstruct was a forward
443// reference, and we really don't know anything about it. (In this case, it
444// will appear to have no methods or members.)
445EXPCL_INTERROGATEDB bool interrogate_type_is_fully_defined(TypeIndex type);
446
447// If is_unpublished() returns false, the classstruct is unknown because it
448// was not marked to be published (or, in promiscuous mode, it is a protected
449// or private nested class).
450EXPCL_INTERROGATEDB bool interrogate_type_is_unpublished(TypeIndex type);
451
452/*
453 * Otherwise, especially if the type is a struct or class, we may have a
454 * number of member functions, including zero or more constructors and zero or
455 * one destructor. A constructor function may be called to allocate a new
456 * instance of the type; its return value will be a pointer to the new
457 * instance. The destructor may be called to destroy the instance; however,
458 * it usually should not be explicitly called by the user, since the proper
459 * support of the interrogate_caller_manages_return_value() interface, above,
460 * will ensure that the appropriate destructors are called when they should
461 * be.
462 */
463
464/*
465 * In certain circumstances, the destructor might be inherited from a parent
466 * or ancestor class. This happens when the destructor wrapper from the
467 * ancestor class is an acceptable substitute for this destructor; this is
468 * only possible in the case of a virtual C++ destructor. In this case, the
469 * destructor returned here will be the same function index as the one
470 * returned by the ancestor class, and
471 * interrogate_type_destructor_is_inherited() will return true for this class.
472 */
473EXPCL_INTERROGATEDB int interrogate_type_number_of_constructors(TypeIndex type);
474EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_constructor(TypeIndex type, int n);
475EXPCL_INTERROGATEDB bool interrogate_type_has_destructor(TypeIndex type);
476EXPCL_INTERROGATEDB bool interrogate_type_destructor_is_inherited(TypeIndex type);
477EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_destructor(TypeIndex type);
478
479// This is the set of exposed data elements in the struct or class.
480EXPCL_INTERROGATEDB int interrogate_type_number_of_elements(TypeIndex type);
481EXPCL_INTERROGATEDB ElementIndex interrogate_type_get_element(TypeIndex type, int n);
482
483// This is the set of exposed member functions in the struct or class.
484EXPCL_INTERROGATEDB int interrogate_type_number_of_methods(TypeIndex type);
485EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_method(TypeIndex type, int n);
486
487// This is the set of MAKE_SEQ wrappers in the struct or class.
488EXPCL_INTERROGATEDB int interrogate_type_number_of_make_seqs(TypeIndex type);
489EXPCL_INTERROGATEDB MakeSeqIndex interrogate_type_get_make_seq(TypeIndex type, int n);
490
491// A C++ class may also define a number of explicit cast operators, which
492// define how to convert an object of this type to an object of some other
493// type (the type can be inferred by the return type of the cast function).
494// This is not related to upcast and downcast, defined below.
495EXPCL_INTERROGATEDB int interrogate_type_number_of_casts(TypeIndex type);
496EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_cast(TypeIndex type, int n);
497
498// A C++ class may inherit from zero or more base classes. This defines the
499// list of base classes for this particular type.
500EXPCL_INTERROGATEDB int interrogate_type_number_of_derivations(TypeIndex type);
501EXPCL_INTERROGATEDB TypeIndex interrogate_type_get_derivation(TypeIndex type, int n);
502
503// For each base class, we might need to define an explicit upcast or downcast
504// operation to convert the pointer to the derived class to an appropriate
505// pointer to its base class (upcast) or vice-versa (downcast). This is
506// particularly true in the presence of multiple inheritance or virtual
507// inheritance, in which case you cannot simply use the same pointer as either
508// type.
509
510// If interrogate_type_derivation_has_upcast() returns true for a particular
511// typederivation combination, you must use the indicated upcast function to
512// convert pointers of this type to pointers of the base type before calling
513// any of the inherited methods from the base class. If this returns false,
514// you may simply use the same pointer as either a derived class pointer or a
515// base class pointer without any extra step.
516EXPCL_INTERROGATEDB bool interrogate_type_derivation_has_upcast(TypeIndex type, int n);
517EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_upcast(TypeIndex type, int n);
518
519/*
520 * Although it is always possible to upcast a pointer to a base class, it is
521 * not always possible to downcast from a base class to the derived class
522 * (particularly in the presence of virtual inheritance). If
523 * interrogate_type_derivation_downcast_is_impossible() returns true, forget
524 * it. Otherwise, downcasting works the same way as upcasting. (Of course,
525 * it is the caller's responsibility to guarantee that the pointer actually
526 * represents an object of the type being downcast to.)
527 */
528EXPCL_INTERROGATEDB bool interrogate_type_derivation_downcast_is_impossible(TypeIndex type, int n);
529EXPCL_INTERROGATEDB bool interrogate_type_derivation_has_downcast(TypeIndex type, int n);
530EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_downcast(TypeIndex type, int n);
531
532// A C++ class may also define any number of nested types--classes or enums
533// defined within the scope of this class.
534EXPCL_INTERROGATEDB int interrogate_type_number_of_nested_types(TypeIndex type);
535EXPCL_INTERROGATEDB TypeIndex interrogate_type_get_nested_type(TypeIndex type, int n);
536
537#ifdef __cplusplus
538}
539#endif
540
541#endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.