Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

dtool/src/interrogatedb/interrogate_interface.h

Go to the documentation of this file.
00001 // Filename: interrogate_interface.h
00002 // Created by:  frang (09Nov99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef INTERROGATE_INTERFACE_H
00020 #define INTERROGATE_INTERFACE_H
00021 
00022 #include <dtoolbase.h>
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 // This file defines the interface to the interrogate database.  This
00029 // database is generated by running interrogate on a package's source
00030 // code; interrogate parses the C++ syntax, determines the public
00031 // interface, generates C-style wrapper functions where necessary, and
00032 // builds up a table of functions and classes and their relationships.
00033 
00034 // Some of this data (in particular, the wrapper functions, and the
00035 // table of unique names for these functions) is linked in along with
00036 // the codebase, permanently a part of the library file, and is always
00037 // available; the rest of it is stored in external files (named *.in)
00038 // and read in when needed.  For this reason, most of the interface
00039 // functions defined here will force a load of the complete
00040 // interrogate database the first time any of them are called.  The
00041 // three exceptions are noted below; they are
00042 // interrogate_wrapper_has_pointer(), interrogate_wrapper_pointer(),
00043 // and interrogate_get_wrapper_by_unique_name().
00044 
00045 
00046 // The interface here is intentionally made to be as simple as
00047 // possible, to maximize portability.  All that is required of a
00048 // scripting language is a foreign function interface capable of
00049 // calling C functions.
00050 
00051 
00052 // In general, the interrogate database consists of a number of query
00053 // functions that allow the caller to walk through the list of
00054 // available types, functions, manifests, etc.  For each of these, a
00055 // unique index number is returned; this index number may then be used
00056 // to query details about the type, function, etc.  The index numbers
00057 // are only guaranteed to remain unchanged during a particular
00058 // session; from one session to another they may differ.
00059 
00060 // All index numbers are ordinary integers.  Each has a unique typedef
00061 // here for clarity of meaning, but they may be treated as ordinary
00062 // integers by the caller.
00063 typedef int ManifestIndex;
00064 typedef int ElementIndex;
00065 typedef int TypeIndex;
00066 typedef int FunctionIndex;
00067 typedef int FunctionWrapperIndex;
00068 
00069 // Atomic types are those that are built in to C.  This enumerated
00070 // value is returned by interrogate_type_atomic_token() when a type is
00071 // known to be one of the atomic types.
00072 enum AtomicToken {
00073   AT_not_atomic = 0,
00074   AT_int = 1,
00075   AT_float = 2,
00076   AT_double = 3,
00077   AT_bool = 4,
00078   AT_char = 5,
00079   AT_void = 6,
00080 
00081   // There isn't an atomic string type in C, but there is one in
00082   // almost all other languages.  If -string is supplied to the
00083   // interrogate command line, functions may be reported as returning
00084   // and accepting objects of type atomic string.  For the C calling
00085   // convention wrappers, atomic string means (const char *); for
00086   // other calling convention wrappers, atomic string means whatever
00087   // the native string representation is.
00088   AT_string = 7
00089 };
00090 
00091 //////////////////////////////////////////////////////////////////////////
00092 //
00093 // Manifest Symbols
00094 //
00095 //////////////////////////////////////////////////////////////////////////
00096 
00097 // These correspond to #define constants that appear in the C code.
00098 // (These are only the manifest constants--those #define's that take
00099 // no parameters.  Manifest functions, #define's that take one or more
00100 // parameters, are not exported.)  They cannot be set, of course, but
00101 // they often have a meaningful value that may be get.  The scripting
00102 // language may choose to get the value as a literal string via
00103 // interrogate_manifest_definition(), or as a value of a particular type
00104 // (whatever type interrogate thinks it is), as returned by the getter
00105 // function given by interrogate_manifest_getter().
00106 
00107 EXPCL_DTOOLCONFIG int interrogate_number_of_manifests();
00108 EXPCL_DTOOLCONFIG ManifestIndex interrogate_get_manifest(int n);
00109 EXPCL_DTOOLCONFIG ManifestIndex interrogate_get_manifest_by_name(const char *manifest_name);
00110 EXPCL_DTOOLCONFIG const char *interrogate_manifest_name(ManifestIndex manifest);
00111 EXPCL_DTOOLCONFIG const char *interrogate_manifest_definition(ManifestIndex manifest);
00112 EXPCL_DTOOLCONFIG bool interrogate_manifest_has_type(ManifestIndex manifest);
00113 EXPCL_DTOOLCONFIG TypeIndex interrogate_manifest_get_type(ManifestIndex manifest);
00114 EXPCL_DTOOLCONFIG bool interrogate_manifest_has_getter(ManifestIndex manifest);
00115 EXPCL_DTOOLCONFIG FunctionIndex interrogate_manifest_getter(ManifestIndex manifest);
00116 
00117 // An exception is made for manifest constants that have an integer
00118 // type value, since these are so common.  The scripting language can
00119 // query these values directly, which saves having to generate a
00120 // wrapper function for each stupid little manifest.  In this case,
00121 // there will be no getter function available.
00122 EXPCL_DTOOLCONFIG bool interrogate_manifest_has_int_value(ManifestIndex manifest);
00123 EXPCL_DTOOLCONFIG int interrogate_manifest_get_int_value(ManifestIndex manifest);
00124 
00125 
00126 //////////////////////////////////////////////////////////////////////////
00127 //
00128 // Data Elements
00129 //
00130 //////////////////////////////////////////////////////////////////////////
00131 
00132 // These correspond to data members of a class, or global data
00133 // elements.  Interrogate automatically generates a getter function
00134 // and, if possible, a setter function.
00135 
00136 EXPCL_DTOOLCONFIG const char *interrogate_element_name(ElementIndex element);
00137 EXPCL_DTOOLCONFIG const char *interrogate_element_scoped_name(ElementIndex element);
00138 EXPCL_DTOOLCONFIG ElementIndex interrogate_get_element_by_name(const char *element_name);
00139 EXPCL_DTOOLCONFIG ElementIndex interrogate_get_element_by_scoped_name(const char *element_name);
00140 
00141 // Be careful with this function.  The element's bare type is not
00142 // likely to be directly useful to the scripting language.  This is a
00143 // different answer than the return value of the getter.
00144 
00145 // The element type might well be something concrete that the
00146 // scripting language can't handle directly, e.g. a Node, while the
00147 // getter will return (and the setter accept) a pointer to a Node,
00148 // which is what the scripting language actually works with.
00149 EXPCL_DTOOLCONFIG TypeIndex interrogate_element_type(ElementIndex element);
00150 
00151 EXPCL_DTOOLCONFIG bool interrogate_element_has_getter(ElementIndex element);
00152 EXPCL_DTOOLCONFIG FunctionIndex interrogate_element_getter(ElementIndex element);
00153 EXPCL_DTOOLCONFIG bool interrogate_element_has_setter(ElementIndex element);
00154 EXPCL_DTOOLCONFIG FunctionIndex interrogate_element_setter(ElementIndex element);
00155 
00156 //////////////////////////////////////////////////////////////////////////
00157 //
00158 // Global Data
00159 //
00160 //////////////////////////////////////////////////////////////////////////
00161 
00162 // This is the list of global data elements.
00163 
00164 EXPCL_DTOOLCONFIG int interrogate_number_of_globals();
00165 EXPCL_DTOOLCONFIG ElementIndex interrogate_get_global(int n);
00166 
00167 //////////////////////////////////////////////////////////////////////////
00168 //
00169 // Functions
00170 //
00171 //////////////////////////////////////////////////////////////////////////
00172 
00173 // There is a unique FunctionIndex associated with each of the
00174 // functions that interrogate knows about.  This includes member
00175 // functions, nonmember functions, synthesized getters and setters,
00176 // and upcast/downcast functions.
00177 
00178 
00179 // These are the global (nonmember) functions that appear outside of
00180 // any class definition.
00181 EXPCL_DTOOLCONFIG int interrogate_number_of_global_functions();
00182 EXPCL_DTOOLCONFIG FunctionIndex interrogate_get_global_function(int n);
00183 
00184 // This can be used to traverse through *all* the functions known to
00185 // interrogate.  It's usually not what you want, since this includes
00186 // global functions, class methods, and synthesized functions like
00187 // upcasts and downcasts.  You probably want to use instead
00188 // interrogate_number_of_global_functions(), above.
00189 EXPCL_DTOOLCONFIG int interrogate_number_of_functions();
00190 EXPCL_DTOOLCONFIG FunctionIndex interrogate_get_function(int n);
00191 
00192 // This is the function's name.  It is not unique; it may be shared
00193 // between multiple different functions that have the same name but
00194 // different parameter types (this is C++'s function overloading).
00195 // Two different classes might also have member functions that have
00196 // the same name, or the same name as a global function (but also see
00197 // the scoped_name, below).
00198 EXPCL_DTOOLCONFIG const char *interrogate_function_name(FunctionIndex function);
00199 
00200 // The scoped name is the function name prefixed with the name of the
00201 // class that includes the function, if the function is a class
00202 // method.  If it is a global function, the scoped name is the same as
00203 // the name returned above.  In the absence of C++ function
00204 // overloading, this name will be unique to each function.
00205 EXPCL_DTOOLCONFIG const char *interrogate_function_scoped_name(FunctionIndex function);
00206 
00207 // This returns the C++ comment written for the function, either in
00208 // the header file or in the .C file, or both.
00209 EXPCL_DTOOLCONFIG bool interrogate_function_has_comment(FunctionIndex function);
00210 EXPCL_DTOOLCONFIG const char *interrogate_function_comment(FunctionIndex function);
00211 
00212 // This defines the function prototype as it appears in the C++
00213 // source, useful primarily for documentation purposes.
00214 EXPCL_DTOOLCONFIG const char *interrogate_function_prototype(FunctionIndex function);
00215 
00216 // This can be used to determine the class that the function is a
00217 // method for, if the function is a class method.
00218 EXPCL_DTOOLCONFIG bool interrogate_function_is_method(FunctionIndex function);
00219 EXPCL_DTOOLCONFIG TypeIndex interrogate_function_class(FunctionIndex function);
00220 
00221 // This returns the module name reported for the function, if
00222 // available.
00223 EXPCL_DTOOLCONFIG bool interrogate_function_has_module_name(FunctionIndex function);
00224 EXPCL_DTOOLCONFIG const char *interrogate_function_module_name(FunctionIndex function);
00225 
00226 // This is true for virtual member functions.  It's not likely that
00227 // this will be important to the scripting language.
00228 EXPCL_DTOOLCONFIG bool interrogate_function_is_virtual(FunctionIndex function);
00229 
00230 
00231 // The actual callable function interface is defined via one or more
00232 // wrappers for each function.  (There might be multiple wrappers for
00233 // the same function to allow for default parameter values.)
00234 
00235 // At present, interrogate can generate wrappers that use the C
00236 // calling convention or the Python calling convention.  The set of
00237 // wrappers that will actually be available depends on the parameters
00238 // passed to the interrogate command line.
00239 EXPCL_DTOOLCONFIG int interrogate_function_number_of_c_wrappers(FunctionIndex function);
00240 EXPCL_DTOOLCONFIG FunctionWrapperIndex interrogate_function_c_wrapper(FunctionIndex function, int n);
00241 
00242 EXPCL_DTOOLCONFIG int interrogate_function_number_of_python_wrappers(FunctionIndex function);
00243 EXPCL_DTOOLCONFIG FunctionWrapperIndex interrogate_function_python_wrapper(FunctionIndex function, int n);
00244 
00245 //////////////////////////////////////////////////////////////////////////
00246 //
00247 // Function wrappers
00248 //
00249 //////////////////////////////////////////////////////////////////////////
00250 
00251 // These define the way to call a given function.  Depending on the
00252 // parameters supplied to interrogate, a function wrapper may be able
00253 // to supply either a void * pointer to the function, or the name of
00254 // the function in the library, or both.
00255 
00256 
00257 // This returns the actual name of the wrapper function, as opposed to
00258 // the name of the function it wraps.  It's probably not terribly
00259 // useful to the scripting language, unless the -fnames option was
00260 // given to interrogate, in which case this name may be used to call
00261 // the wrapper function (see is_callable_by_name, below).  It will
00262 // usually be an ugly hashed name, not intended for human consumption.
00263 
00264 // Don't confuse this with the unique_name, below.  The two are
00265 // related, but not identical.
00266 EXPCL_DTOOLCONFIG const char *interrogate_wrapper_name(FunctionWrapperIndex wrapper);
00267 
00268 // This returns true if -fnames was given to interrogate, making the
00269 // wrapper function callable directly by its name.
00270 EXPCL_DTOOLCONFIG bool interrogate_wrapper_is_callable_by_name(FunctionWrapperIndex wrapper);
00271 
00272 // Every function wrapper has zero or more parameters and may or may
00273 // not have a return value.  Each parameter has a type and may or may
00274 // not have a name.  For member functions, the first parameter may be
00275 // a 'this' parameter, which should receive a pointer to the class
00276 // object.  (If a member function does not have a 'this' parameter as
00277 // its first parameter, it is a static member function, also called a
00278 // class method.)
00279 
00280 EXPCL_DTOOLCONFIG bool interrogate_wrapper_has_return_value(FunctionWrapperIndex wrapper);
00281 EXPCL_DTOOLCONFIG TypeIndex interrogate_wrapper_return_type(FunctionWrapperIndex wrapper);
00282 
00283 // Sometimes interrogate must synthesize a wrapper that allocates its
00284 // return value from the free store.  Other times (especially if
00285 // -refcount is supplied to interrogate), interrogate will
00286 // automatically increment the count of a reference-counted object
00287 // that it returns.  In cases like these,
00288 // interrogate_wrapper_caller_manages_return_value() will return true,
00289 // and it is the responsibility of the scripting language to
00290 // eventually call the destructor supplied by
00291 // interrogate_wrapper_return_value_destructor() on this value when it
00292 // is no longer needed (which will generally be the same destructor as
00293 // that for the class).  Otherwise, this function will return false,
00294 // and the scripting language should *not* call any destructor on this
00295 // value.
00296 EXPCL_DTOOLCONFIG bool interrogate_wrapper_caller_manages_return_value(FunctionWrapperIndex wrapper);
00297 EXPCL_DTOOLCONFIG FunctionIndex interrogate_wrapper_return_value_destructor(FunctionWrapperIndex wrapper);
00298 
00299 // These define the parameters of the function.
00300 EXPCL_DTOOLCONFIG int interrogate_wrapper_number_of_parameters(FunctionWrapperIndex wrapper);
00301 EXPCL_DTOOLCONFIG TypeIndex interrogate_wrapper_parameter_type(FunctionWrapperIndex wrapper, int n);
00302 EXPCL_DTOOLCONFIG bool interrogate_wrapper_parameter_has_name(FunctionWrapperIndex wrapper, int n);
00303 EXPCL_DTOOLCONFIG const char *interrogate_wrapper_parameter_name(FunctionWrapperIndex wrapper, int n);
00304 EXPCL_DTOOLCONFIG bool interrogate_wrapper_parameter_is_this(FunctionWrapperIndex wrapper, int n);
00305 
00306 // This returns a pointer to a function that may be called to invoke
00307 // the function, if the -fptrs option to return function pointers was
00308 // specified to interrogate.  Be sure to push the required parameters
00309 // on the stack, according to the calling convention, before calling
00310 // the function.
00311 
00312 // These two functions may be called without forcing a load of the
00313 // complete interrogate database.
00314 EXPCL_DTOOLCONFIG bool interrogate_wrapper_has_pointer(FunctionWrapperIndex wrapper);
00315 EXPCL_DTOOLCONFIG void *interrogate_wrapper_pointer(FunctionWrapperIndex wrapper);
00316 
00317 // This function will return a name that is guaranteed to be unique to
00318 // this particular function wrapper, and that will (usually) be
00319 // consistent across multiple runtime sessions.  (It will only change
00320 // between sessions if the database was regenerated in the interim
00321 // with some new function that happened to introduce a hash conflict.)
00322 
00323 // The unique name is an ugly hashed name, not safe for human
00324 // consumption.  Its sole purpose is to provide some consistent way to
00325 // identify function wrappers between sessions.
00326 EXPCL_DTOOLCONFIG const char *interrogate_wrapper_unique_name(FunctionWrapperIndex wrapper);
00327 
00328 // This function provides a reverse-lookup on the above unique name,
00329 // returning the wrapper index corresponding to the given name.  It
00330 // depends on data having been compiled directly into the library, and
00331 // thus is only available if the option -unique-names was given to
00332 // interrogate.
00333 
00334 // This function may be called without forcing a load of the complete
00335 // interrogate database.
00336 EXPCL_DTOOLCONFIG FunctionWrapperIndex interrogate_get_wrapper_by_unique_name(const char *unique_name);
00337 
00338 
00339 //////////////////////////////////////////////////////////////////////////
00340 //
00341 // Types
00342 //
00343 //////////////////////////////////////////////////////////////////////////
00344 
00345 // These are all the types that interrogate knows about.  This
00346 // includes atomic types like ints and floats, type wrappers like
00347 // pointers and const pointers, enumerated types, and classes.
00348 
00349 // Two lists of types are maintained: the list of global types, which
00350 // includes only those types intended to be wrapped in the API (for
00351 // instance, all of the classes).  The second list is the complete
00352 // list of all types, which probably does not need to be
00353 // traversed--this includes *all* types known to the interrogate
00354 // database, including simple types and pointers and const pointers to
00355 // classes.  These types are necessary to fully define all of the
00356 // function parameters, but need not themselves be wrapped.
00357 
00358 EXPCL_DTOOLCONFIG int interrogate_number_of_global_types();
00359 EXPCL_DTOOLCONFIG TypeIndex interrogate_get_global_type(int n);
00360 EXPCL_DTOOLCONFIG int interrogate_number_of_types();
00361 EXPCL_DTOOLCONFIG TypeIndex interrogate_get_type(int n);
00362 EXPCL_DTOOLCONFIG TypeIndex interrogate_get_type_by_name(const char *type_name);
00363 EXPCL_DTOOLCONFIG TypeIndex interrogate_get_type_by_scoped_name(const char *type_name);
00364 EXPCL_DTOOLCONFIG TypeIndex interrogate_get_type_by_true_name(const char *type_name);
00365 EXPCL_DTOOLCONFIG const char *interrogate_type_name(TypeIndex type);
00366 EXPCL_DTOOLCONFIG const char *interrogate_type_scoped_name(TypeIndex type);
00367 EXPCL_DTOOLCONFIG const char *interrogate_type_true_name(TypeIndex type);
00368 
00369 // A given type might be a nested type, meaning it is entirely defined
00370 // within (and scoped within) some different C++ class.  In this case,
00371 // the type_name() will return the local name of the type as seen
00372 // within the class, while the scoped_name() will return the
00373 // fully-qualified name of the type, and is_nested() and outer_class()
00374 // can be used to determine the class it is nested within.
00375 EXPCL_DTOOLCONFIG bool interrogate_type_is_nested(TypeIndex type);
00376 EXPCL_DTOOLCONFIG TypeIndex interrogate_type_outer_class(TypeIndex type);
00377 
00378 EXPCL_DTOOLCONFIG bool interrogate_type_has_comment(TypeIndex type);
00379 EXPCL_DTOOLCONFIG const char *interrogate_type_comment(TypeIndex type);
00380 
00381 // This returns the module name reported for the type, if available.
00382 EXPCL_DTOOLCONFIG bool interrogate_type_has_module_name(TypeIndex type);
00383 EXPCL_DTOOLCONFIG const char *interrogate_type_module_name(TypeIndex type);
00384 
00385 // If interrogate_type_is_atomic() returns true, the type is one of
00386 // the basic C types enumerated in AtomicToken, above.  The type may
00387 // then be further modified by one or more of unsigned, signed, long,
00388 // longlong, or short.  However, it will not be a pointer.
00389 EXPCL_DTOOLCONFIG bool interrogate_type_is_atomic(TypeIndex type);
00390 EXPCL_DTOOLCONFIG AtomicToken interrogate_type_atomic_token(TypeIndex type);
00391 EXPCL_DTOOLCONFIG bool interrogate_type_is_unsigned(TypeIndex type);
00392 EXPCL_DTOOLCONFIG bool interrogate_type_is_signed(TypeIndex type);
00393 EXPCL_DTOOLCONFIG bool interrogate_type_is_long(TypeIndex type);
00394 EXPCL_DTOOLCONFIG bool interrogate_type_is_longlong(TypeIndex type);
00395 EXPCL_DTOOLCONFIG bool interrogate_type_is_short(TypeIndex type);
00396 
00397 // If interrogate_type_is_wrapped() returns true, this is a composite
00398 // type "wrapped" around some simpler type, for instance a pointer to
00399 // a class.  The type will be either a pointer or a const wrapper--it
00400 // cannot be a combination of these.  (When combinations are required,
00401 // they use multiple wrappers.  A const char pointer, for example, is
00402 // represented as a pointer wrapper around a const wrapper around an
00403 // atomic char.)
00404 EXPCL_DTOOLCONFIG bool interrogate_type_is_wrapped(TypeIndex type);
00405 EXPCL_DTOOLCONFIG bool interrogate_type_is_pointer(TypeIndex type);
00406 EXPCL_DTOOLCONFIG bool interrogate_type_is_const(TypeIndex type);
00407 EXPCL_DTOOLCONFIG TypeIndex interrogate_type_wrapped_type(TypeIndex type);
00408 
00409 // If interrogate_type_is_enum() returns true, this is an enumerated
00410 // type, which means it may take any one of a number of named integer
00411 // values.
00412 EXPCL_DTOOLCONFIG bool interrogate_type_is_enum(TypeIndex type);
00413 EXPCL_DTOOLCONFIG int interrogate_type_number_of_enum_values(TypeIndex type);
00414 EXPCL_DTOOLCONFIG const char *interrogate_type_enum_value_name(TypeIndex type, int n);
00415 EXPCL_DTOOLCONFIG const char *interrogate_type_enum_value_scoped_name(TypeIndex type, int n);
00416 EXPCL_DTOOLCONFIG int interrogate_type_enum_value(TypeIndex type, int n);
00417 
00418 // If none of the above is true, the type is some extension type.  It
00419 // may be a struct, class, or union (and the distinction between these
00420 // three is not likely to be important to the scripting language).  In
00421 // any case, it may contain zero or more constructors, zero or one
00422 // destructor, zero or more member functions, and zero or more data
00423 // members; all of the remaining type functions may apply.
00424 EXPCL_DTOOLCONFIG bool interrogate_type_is_struct(TypeIndex type);
00425 EXPCL_DTOOLCONFIG bool interrogate_type_is_class(TypeIndex type);
00426 EXPCL_DTOOLCONFIG bool interrogate_type_is_union(TypeIndex type);
00427 
00428 // If is_fully_defined() returns false, this class/struct was a
00429 // forward reference, and we really don't know anything about it.  (In
00430 // this case, it will appear to have no methods or members.)
00431 EXPCL_DTOOLCONFIG bool interrogate_type_is_fully_defined(TypeIndex type);
00432 
00433 // If is_unpublished() returns false, the class/struct is unknown
00434 // because it was not marked to be published (or, in promiscuous mode,
00435 // it is a protected or private nested class).
00436 EXPCL_DTOOLCONFIG bool interrogate_type_is_unpublished(TypeIndex type);
00437 
00438 // Otherwise, especially if the type is a struct or class, we may have
00439 // a number of member functions, including zero or more constructors
00440 // and zero or one destructor.  A constructor function may be called
00441 // to allocate a new instance of the type; its return value will be a
00442 // pointer to the new instance.  The destructor may be called to
00443 // destroy the instance; however, it usually should not be explicitly
00444 // called by the user, since the proper support of the
00445 // interrogate_caller_manages_return_value() interface, above, will
00446 // ensure that the appropriate destructors are called when they should
00447 // be.
00448 
00449 // In certain circumstances, the destructor might be inherited from a
00450 // parent or ancestor class.  This happens when the destructor wrapper
00451 // from the ancestor class is an acceptable substitute for this
00452 // destructor; this is only possible in the case of a virtual C++
00453 // destructor.  In this case, the destructor returned here will be the
00454 // same function index as the one returned by the ancestor class, and
00455 // interrogate_type_destructor_is_inherited() will return true for
00456 // this class.
00457 EXPCL_DTOOLCONFIG int interrogate_type_number_of_constructors(TypeIndex type);
00458 EXPCL_DTOOLCONFIG FunctionIndex interrogate_type_get_constructor(TypeIndex type, int n);
00459 EXPCL_DTOOLCONFIG bool interrogate_type_has_destructor(TypeIndex type);
00460 EXPCL_DTOOLCONFIG bool interrogate_type_destructor_is_inherited(TypeIndex type);
00461 EXPCL_DTOOLCONFIG FunctionIndex interrogate_type_get_destructor(TypeIndex type);
00462 
00463 // This is the set of exposed data elements in the struct or class.
00464 EXPCL_DTOOLCONFIG int interrogate_type_number_of_elements(TypeIndex type);
00465 EXPCL_DTOOLCONFIG ElementIndex interrogate_type_get_element(TypeIndex type, int n);
00466 
00467 // This is the set of exposed member functions in the struct or class.
00468 EXPCL_DTOOLCONFIG int interrogate_type_number_of_methods(TypeIndex type);
00469 EXPCL_DTOOLCONFIG FunctionIndex interrogate_type_get_method(TypeIndex type, int n);
00470 
00471 // A C++ class may also define a number of explicit cast operators,
00472 // which define how to convert an object of this type to an object of
00473 // some other type (the type can be inferred by the return type of the
00474 // cast function).  This is not related to upcast and downcast,
00475 // defined below.
00476 EXPCL_DTOOLCONFIG int interrogate_type_number_of_casts(TypeIndex type);
00477 EXPCL_DTOOLCONFIG FunctionIndex interrogate_type_get_cast(TypeIndex type, int n);
00478 
00479 // A C++ class may inherit from zero or more base classes.  This
00480 // defines the list of base classes for this particular type.
00481 EXPCL_DTOOLCONFIG int interrogate_type_number_of_derivations(TypeIndex type);
00482 EXPCL_DTOOLCONFIG TypeIndex interrogate_type_get_derivation(TypeIndex type, int n);
00483 
00484 // For each base class, we might need to define an explicit upcast or
00485 // downcast operation to convert the pointer to the derived class to
00486 // an appropriate pointer to its base class (upcast) or vice-versa
00487 // (downcast).  This is particularly true in the presence of multiple
00488 // inheritance or virtual inheritance, in which case you cannot simply
00489 // use the same pointer as either type.
00490 
00491 // If interrogate_type_derivation_has_upcast() returns true for a
00492 // particular type/derivation combination, you must use the indicated
00493 // upcast function to convert pointers of this type to pointers of the
00494 // base type before calling any of the inherited methods from the base
00495 // class.  If this returns false, you may simply use the same pointer
00496 // as either a derived class pointer or a base class pointer without
00497 // any extra step.
00498 EXPCL_DTOOLCONFIG bool interrogate_type_derivation_has_upcast(TypeIndex type, int n);
00499 EXPCL_DTOOLCONFIG FunctionIndex interrogate_type_get_upcast(TypeIndex type, int n);
00500 
00501 // Although it is always possible to upcast a pointer to a base class,
00502 // it is not always possible to downcast from a base class to the
00503 // derived class (particularly in the presence of virtual
00504 // inheritance).  If interrogate_type_derivation_downcast_is_impossible()
00505 // returns true, forget it.  Otherwise, downcasting works the same
00506 // way as upcasting.  (Of course, it is the caller's responsibility to
00507 // guarantee that the pointer actually represents an object of the
00508 // type being downcast to.)
00509 EXPCL_DTOOLCONFIG bool interrogate_type_derivation_downcast_is_impossible(TypeIndex type, int n);
00510 EXPCL_DTOOLCONFIG bool interrogate_type_derivation_has_downcast(TypeIndex type, int n);
00511 EXPCL_DTOOLCONFIG FunctionIndex interrogate_type_get_downcast(TypeIndex type, int n);
00512 
00513 // A C++ class may also define any number of nested types--classes or
00514 // enums defined within the scope of this class.
00515 EXPCL_DTOOLCONFIG int interrogate_type_number_of_nested_types(TypeIndex type);
00516 EXPCL_DTOOLCONFIG TypeIndex interrogate_type_get_nested_type(TypeIndex type, int n);
00517 
00518 #ifdef __cplusplus
00519 }
00520 #endif
00521 
00522 #endif

Generated on Thu May 1 22:13:05 2003 for DTool by doxygen1.3