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);
213EXPCL_INTERROGATEDB bool interrogate_function_is_unary_op(FunctionIndex function);
214EXPCL_INTERROGATEDB bool interrogate_function_is_operator_typecast(FunctionIndex function);
215EXPCL_INTERROGATEDB bool interrogate_function_is_constructor(FunctionIndex function);
216EXPCL_INTERROGATEDB bool interrogate_function_is_destructor(FunctionIndex function);
217
218// This returns the module name reported for the function, if available.
219EXPCL_INTERROGATEDB bool interrogate_function_has_module_name(FunctionIndex function);
220EXPCL_INTERROGATEDB const char *interrogate_function_module_name(FunctionIndex function);
221
222// This returns the library name reported for the function, if available.
223EXPCL_INTERROGATEDB bool interrogate_function_has_library_name(FunctionIndex function);
224EXPCL_INTERROGATEDB const char *interrogate_function_library_name(FunctionIndex function);
225
226// This is true for virtual member functions. It's not likely that this will
227// be important to the scripting language.
228EXPCL_INTERROGATEDB bool interrogate_function_is_virtual(FunctionIndex function);
229
230
231// The actual callable function interface is defined via one or more wrappers
232// for each function. (There might be multiple wrappers for the same function
233// to allow for default parameter values.)
234
235// At present, interrogate can generate wrappers that use the C calling
236// convention or the Python calling convention. The set of wrappers that will
237// actually be available depends on the parameters passed to the interrogate
238// command line.
239EXPCL_INTERROGATEDB int interrogate_function_number_of_c_wrappers(FunctionIndex function);
240EXPCL_INTERROGATEDB FunctionWrapperIndex interrogate_function_c_wrapper(FunctionIndex function, int n);
241
242EXPCL_INTERROGATEDB int interrogate_function_number_of_python_wrappers(FunctionIndex function);
243EXPCL_INTERROGATEDB FunctionWrapperIndex interrogate_function_python_wrapper(FunctionIndex function, int n);
244
245// Function wrappers
246
247// These define the way to call a given function. Depending on the parameters
248// supplied to interrogate, a function wrapper may be able to supply either a
249// void * pointer to the function, or the name of the function in the library,
250// or both.
251
252
253// This returns the actual name of the wrapper function, as opposed to the
254// name of the function it wraps. It's probably not terribly useful to the
255// scripting language, unless the -fnames option was given to interrogate, in
256// which case this name may be used to call the wrapper function (see
257// is_callable_by_name, below). It will usually be an ugly hashed name, not
258// intended for human consumption.
259
260// Don't confuse this with the unique_name, below. The two are related, but
261// not identical.
262EXPCL_INTERROGATEDB const char *interrogate_wrapper_name(FunctionWrapperIndex wrapper);
263
264// This returns true if -fnames was given to interrogate, making the wrapper
265// function callable directly by its name.
266EXPCL_INTERROGATEDB bool interrogate_wrapper_is_callable_by_name(FunctionWrapperIndex wrapper);
267
268// This returns the C++ comment written for the function wrapper, usually from
269// the .cpp file. There may be a different comment for each overload of a
270// given function.
271EXPCL_INTERROGATEDB bool interrogate_wrapper_has_comment(FunctionWrapperIndex wrapper);
272EXPCL_INTERROGATEDB const char *interrogate_wrapper_comment(FunctionWrapperIndex wrapper);
273
274// Every function wrapper has zero or more parameters and may or may not have
275// a return value. Each parameter has a type and may or may not have a name.
276// For member functions, the first parameter may be a 'this' parameter, which
277// should receive a pointer to the class object. (If a member function does
278// not have a 'this' parameter as its first parameter, it is a static member
279// function, also called a class method.)
280
281EXPCL_INTERROGATEDB bool interrogate_wrapper_has_return_value(FunctionWrapperIndex wrapper);
282EXPCL_INTERROGATEDB TypeIndex interrogate_wrapper_return_type(FunctionWrapperIndex wrapper);
283
284/*
285 * Sometimes interrogate must synthesize a wrapper that allocates its return
286 * value from the free store. Other times (especially if -refcount is
287 * supplied to interrogate), interrogate will automatically increment the
288 * count of a reference-counted object that it returns. In cases like these,
289 * interrogate_wrapper_caller_manages_return_value() will return true, and it
290 * is the responsibility of the scripting language to eventually call the
291 * destructor supplied by interrogate_wrapper_return_value_destructor() on
292 * this value when it is no longer needed (which will generally be the same
293 * destructor as that for the class). Otherwise, this function will return
294 * false, and the scripting language should *not* call any destructor on this
295 * value.
296 */
297EXPCL_INTERROGATEDB bool interrogate_wrapper_caller_manages_return_value(FunctionWrapperIndex wrapper);
298EXPCL_INTERROGATEDB FunctionIndex interrogate_wrapper_return_value_destructor(FunctionWrapperIndex wrapper);
299
300// These define the parameters of the function.
301EXPCL_INTERROGATEDB int interrogate_wrapper_number_of_parameters(FunctionWrapperIndex wrapper);
302EXPCL_INTERROGATEDB TypeIndex interrogate_wrapper_parameter_type(FunctionWrapperIndex wrapper, int n);
303EXPCL_INTERROGATEDB bool interrogate_wrapper_parameter_has_name(FunctionWrapperIndex wrapper, int n);
304EXPCL_INTERROGATEDB const char *interrogate_wrapper_parameter_name(FunctionWrapperIndex wrapper, int n);
305EXPCL_INTERROGATEDB bool interrogate_wrapper_parameter_is_this(FunctionWrapperIndex wrapper, int n);
306EXPCL_INTERROGATEDB bool interrogate_wrapper_parameter_is_optional(FunctionWrapperIndex wrapper, int n);
307
308// This returns a pointer to a function that may be called to invoke the
309// function, if the -fptrs option to return function pointers was specified to
310// interrogate. Be sure to push the required parameters on the stack,
311// according to the calling convention, before calling the function.
312
313// These two functions may be called without forcing a load of the complete
314// interrogate database.
315EXPCL_INTERROGATEDB bool interrogate_wrapper_has_pointer(FunctionWrapperIndex wrapper);
316EXPCL_INTERROGATEDB void *interrogate_wrapper_pointer(FunctionWrapperIndex wrapper);
317
318// This function will return a name that is guaranteed to be unique to this
319// particular function wrapper, and that will (usually) be consistent across
320// multiple runtime sessions. (It will only change between sessions if the
321// database was regenerated in the interim with some new function that
322// happened to introduce a hash conflict.)
323
324// The unique name is an ugly hashed name, not safe for human consumption.
325// Its sole purpose is to provide some consistent way to identify function
326// wrappers between sessions.
327EXPCL_INTERROGATEDB const char *interrogate_wrapper_unique_name(FunctionWrapperIndex wrapper);
328
329// This function provides a reverse-lookup on the above unique name, returning
330// the wrapper index corresponding to the given name. It depends on data
331// having been compiled directly into the library, and thus is only available
332// if the option -unique-names was given to interrogate.
333
334// This function may be called without forcing a load of the complete
335// interrogate database.
336EXPCL_INTERROGATEDB FunctionWrapperIndex interrogate_get_wrapper_by_unique_name(const char *unique_name);
337
338// MakeSeqs
339
340// These are special synthesized methods that iterate through a list. They
341// are generated in C++ code via the MAKE_SEQ macro. The normal pattern is
342// that a pair of actual C++ methods like get_num_things() and get_thing(n)
343// are used to synthesize a new method called get_things().
344
345EXPCL_INTERROGATEDB const char *interrogate_make_seq_seq_name(MakeSeqIndex make_seq);
346EXPCL_INTERROGATEDB const char *interrogate_make_seq_scoped_name(MakeSeqIndex make_seq);
347EXPCL_INTERROGATEDB bool interrogate_make_seq_has_comment(ElementIndex element);
348EXPCL_INTERROGATEDB const char *interrogate_make_seq_comment(ElementIndex element);
349// The name of the real method that returns the length, e.g. "get_num_things"
350EXPCL_INTERROGATEDB const char *interrogate_make_seq_num_name(MakeSeqIndex make_seq);
351// The name of the real method that returns the nth element, e.g. "get_thing"
352EXPCL_INTERROGATEDB const char *interrogate_make_seq_element_name(MakeSeqIndex make_seq);
353EXPCL_INTERROGATEDB FunctionIndex interrogate_make_seq_num_getter(MakeSeqIndex make_seq);
354EXPCL_INTERROGATEDB FunctionIndex interrogate_make_seq_element_getter(MakeSeqIndex make_seq);
355
356// Types
357
358// These are all the types that interrogate knows about. This includes atomic
359// types like ints and floats, type wrappers like pointers and const pointers,
360// enumerated types, and classes.
361
362/*
363 * Two lists of types are maintained: the list of global types, which includes
364 * only those types intended to be wrapped in the API (for instance, all of
365 * the classes). The second list is the complete list of all types, which
366 * probably does not need to be traversed--this includes *all* types known to
367 * the interrogate database, including simple types and pointers and const
368 * pointers to classes. These types are necessary to fully define all of the
369 * function parameters, but need not themselves be wrapped.
370 */
371
372EXPCL_INTERROGATEDB int interrogate_number_of_global_types();
373EXPCL_INTERROGATEDB TypeIndex interrogate_get_global_type(int n);
374EXPCL_INTERROGATEDB int interrogate_number_of_types();
375EXPCL_INTERROGATEDB TypeIndex interrogate_get_type(int n);
376EXPCL_INTERROGATEDB TypeIndex interrogate_get_type_by_name(const char *type_name);
377EXPCL_INTERROGATEDB TypeIndex interrogate_get_type_by_scoped_name(const char *type_name);
378EXPCL_INTERROGATEDB TypeIndex interrogate_get_type_by_true_name(const char *type_name);
379EXPCL_INTERROGATEDB bool interrogate_type_is_global(TypeIndex type);
380EXPCL_INTERROGATEDB const char *interrogate_type_name(TypeIndex type);
381EXPCL_INTERROGATEDB const char *interrogate_type_scoped_name(TypeIndex type);
382EXPCL_INTERROGATEDB const char *interrogate_type_true_name(TypeIndex type);
383
384// A given type might be a nested type, meaning it is entirely defined within
385// (and scoped within) some different C++ class. In this case, the
386// type_name() will return the local name of the type as seen within the
387// class, while the scoped_name() will return the fully-qualified name of the
388// type, and is_nested() and outer_class() can be used to determine the class
389// it is nested within.
390EXPCL_INTERROGATEDB bool interrogate_type_is_nested(TypeIndex type);
391EXPCL_INTERROGATEDB TypeIndex interrogate_type_outer_class(TypeIndex type);
392
393EXPCL_INTERROGATEDB bool interrogate_type_has_comment(TypeIndex type);
394EXPCL_INTERROGATEDB const char *interrogate_type_comment(TypeIndex type);
395
396// This returns the module name reported for the type, if available.
397EXPCL_INTERROGATEDB bool interrogate_type_has_module_name(TypeIndex type);
398EXPCL_INTERROGATEDB const char *interrogate_type_module_name(TypeIndex type);
399
400// This returns the library name reported for the type, if available.
401EXPCL_INTERROGATEDB bool interrogate_type_has_library_name(TypeIndex type);
402EXPCL_INTERROGATEDB const char *interrogate_type_library_name(TypeIndex type);
403
404
405// If interrogate_type_is_atomic() returns true, the type is one of the basic
406// C types enumerated in AtomicToken, above. The type may then be further
407// modified by one or more of unsigned, signed, long, longlong, or short.
408// However, it will not be a pointer.
409EXPCL_INTERROGATEDB bool interrogate_type_is_atomic(TypeIndex type);
410EXPCL_INTERROGATEDB AtomicToken interrogate_type_atomic_token(TypeIndex type);
411EXPCL_INTERROGATEDB bool interrogate_type_is_unsigned(TypeIndex type);
412EXPCL_INTERROGATEDB bool interrogate_type_is_signed(TypeIndex type);
413EXPCL_INTERROGATEDB bool interrogate_type_is_long(TypeIndex type);
414EXPCL_INTERROGATEDB bool interrogate_type_is_longlong(TypeIndex type);
415EXPCL_INTERROGATEDB bool interrogate_type_is_short(TypeIndex type);
416
417// If interrogate_type_is_wrapped() returns true, this is a composite type
418// "wrapped" around some simpler type, for instance a pointer to a class. The
419// type will be either a pointer or a const wrapper--it cannot be a
420// combination of these. (When combinations are required, they use multiple
421// wrappers. A const char pointer, for example, is represented as a pointer
422// wrapper around a const wrapper around an atomic char.)
423EXPCL_INTERROGATEDB bool interrogate_type_is_wrapped(TypeIndex type);
424EXPCL_INTERROGATEDB bool interrogate_type_is_pointer(TypeIndex type);
425EXPCL_INTERROGATEDB bool interrogate_type_is_const(TypeIndex type);
426EXPCL_INTERROGATEDB bool interrogate_type_is_typedef(TypeIndex type);
427EXPCL_INTERROGATEDB TypeIndex interrogate_type_wrapped_type(TypeIndex type);
428
429// If interrogate_type_is_array() returns true, this is an array type.
430EXPCL_INTERROGATEDB bool interrogate_type_is_array(TypeIndex type);
431EXPCL_INTERROGATEDB int interrogate_type_array_size(TypeIndex type);
432
433// If interrogate_type_is_enum() returns true, this is an enumerated type,
434// which means it may take any one of a number of named integer values.
435EXPCL_INTERROGATEDB bool interrogate_type_is_enum(TypeIndex type);
436EXPCL_INTERROGATEDB bool interrogate_type_is_scoped_enum(TypeIndex type);
437EXPCL_INTERROGATEDB int interrogate_type_number_of_enum_values(TypeIndex type);
438EXPCL_INTERROGATEDB const char *interrogate_type_enum_value_name(TypeIndex type, int n);
439EXPCL_INTERROGATEDB const char *interrogate_type_enum_value_scoped_name(TypeIndex type, int n);
440EXPCL_INTERROGATEDB const char *interrogate_type_enum_value_comment(TypeIndex type, int n);
441EXPCL_INTERROGATEDB int interrogate_type_enum_value(TypeIndex type, int n);
442
443// If none of the above is true, the type is some extension type. It may be a
444// struct, class, or union (and the distinction between these three is not
445// likely to be important to the scripting language). In any case, it may
446// contain zero or more constructors, zero or one destructor, zero or more
447// member functions, and zero or more data members; all of the remaining type
448// functions may apply.
449EXPCL_INTERROGATEDB bool interrogate_type_is_struct(TypeIndex type);
450EXPCL_INTERROGATEDB bool interrogate_type_is_class(TypeIndex type);
451EXPCL_INTERROGATEDB bool interrogate_type_is_union(TypeIndex type);
452
453// If is_fully_defined() returns false, this classstruct was a forward
454// reference, and we really don't know anything about it. (In this case, it
455// will appear to have no methods or members.)
456EXPCL_INTERROGATEDB bool interrogate_type_is_fully_defined(TypeIndex type);
457
458// If is_unpublished() returns false, the classstruct is unknown because it
459// was not marked to be published (or, in promiscuous mode, it is a protected
460// or private nested class).
461EXPCL_INTERROGATEDB bool interrogate_type_is_unpublished(TypeIndex type);
462
463/*
464 * Otherwise, especially if the type is a struct or class, we may have a
465 * number of member functions, including zero or more constructors and zero or
466 * one destructor. A constructor function may be called to allocate a new
467 * instance of the type; its return value will be a pointer to the new
468 * instance. The destructor may be called to destroy the instance; however,
469 * it usually should not be explicitly called by the user, since the proper
470 * support of the interrogate_caller_manages_return_value() interface, above,
471 * will ensure that the appropriate destructors are called when they should
472 * be.
473 */
474
475/*
476 * In certain circumstances, the destructor might be inherited from a parent
477 * or ancestor class. This happens when the destructor wrapper from the
478 * ancestor class is an acceptable substitute for this destructor; this is
479 * only possible in the case of a virtual C++ destructor. In this case, the
480 * destructor returned here will be the same function index as the one
481 * returned by the ancestor class, and
482 * interrogate_type_destructor_is_inherited() will return true for this class.
483 */
484EXPCL_INTERROGATEDB int interrogate_type_number_of_constructors(TypeIndex type);
485EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_constructor(TypeIndex type, int n);
486EXPCL_INTERROGATEDB bool interrogate_type_has_destructor(TypeIndex type);
487EXPCL_INTERROGATEDB bool interrogate_type_destructor_is_inherited(TypeIndex type);
488EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_destructor(TypeIndex type);
489
490// This is the set of exposed data elements in the struct or class.
491EXPCL_INTERROGATEDB int interrogate_type_number_of_elements(TypeIndex type);
492EXPCL_INTERROGATEDB ElementIndex interrogate_type_get_element(TypeIndex type, int n);
493
494// This is the set of exposed member functions in the struct or class.
495EXPCL_INTERROGATEDB int interrogate_type_number_of_methods(TypeIndex type);
496EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_method(TypeIndex type, int n);
497
498// This is the set of MAKE_SEQ wrappers in the struct or class.
499EXPCL_INTERROGATEDB int interrogate_type_number_of_make_seqs(TypeIndex type);
500EXPCL_INTERROGATEDB MakeSeqIndex interrogate_type_get_make_seq(TypeIndex type, int n);
501
502// A C++ class may also define a number of explicit cast operators, which
503// define how to convert an object of this type to an object of some other
504// type (the type can be inferred by the return type of the cast function).
505// This is not related to upcast and downcast, defined below.
506EXPCL_INTERROGATEDB int interrogate_type_number_of_casts(TypeIndex type);
507EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_cast(TypeIndex type, int n);
508
509// A C++ class may inherit from zero or more base classes. This defines the
510// list of base classes for this particular type.
511EXPCL_INTERROGATEDB int interrogate_type_number_of_derivations(TypeIndex type);
512EXPCL_INTERROGATEDB TypeIndex interrogate_type_get_derivation(TypeIndex type, int n);
513EXPCL_INTERROGATEDB bool interrogate_type_is_final(TypeIndex type);
514
515// For each base class, we might need to define an explicit upcast or downcast
516// operation to convert the pointer to the derived class to an appropriate
517// pointer to its base class (upcast) or vice-versa (downcast). This is
518// particularly true in the presence of multiple inheritance or virtual
519// inheritance, in which case you cannot simply use the same pointer as either
520// type.
521
522// If interrogate_type_derivation_has_upcast() returns true for a particular
523// typederivation combination, you must use the indicated upcast function to
524// convert pointers of this type to pointers of the base type before calling
525// any of the inherited methods from the base class. If this returns false,
526// you may simply use the same pointer as either a derived class pointer or a
527// base class pointer without any extra step.
528EXPCL_INTERROGATEDB bool interrogate_type_derivation_has_upcast(TypeIndex type, int n);
529EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_upcast(TypeIndex type, int n);
530
531/*
532 * Although it is always possible to upcast a pointer to a base class, it is
533 * not always possible to downcast from a base class to the derived class
534 * (particularly in the presence of virtual inheritance). If
535 * interrogate_type_derivation_downcast_is_impossible() returns true, forget
536 * it. Otherwise, downcasting works the same way as upcasting. (Of course,
537 * it is the caller's responsibility to guarantee that the pointer actually
538 * represents an object of the type being downcast to.)
539 */
540EXPCL_INTERROGATEDB bool interrogate_type_derivation_downcast_is_impossible(TypeIndex type, int n);
541EXPCL_INTERROGATEDB bool interrogate_type_derivation_has_downcast(TypeIndex type, int n);
542EXPCL_INTERROGATEDB FunctionIndex interrogate_type_get_downcast(TypeIndex type, int n);
543
544// A C++ class may also define any number of nested types--classes or enums
545// defined within the scope of this class.
546EXPCL_INTERROGATEDB int interrogate_type_number_of_nested_types(TypeIndex type);
547EXPCL_INTERROGATEDB TypeIndex interrogate_type_get_nested_type(TypeIndex type, int n);
548
549#ifdef __cplusplus
550}
551#endif
552
553#endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.