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

InterrogateBuilder Class Reference

This class builds up the InterrogateDatabase based on the data indicated by CPPParser after reading the source code. More...

#include <interrogateBuilder.h>

List of all members.

Public Member Functions

void add_source_file (const string &filename)
 Adds the given source filename to the list of files that we are scanning.

void read_command_file (istream &in)
 Reads a .N file that might contain control information for the interrogate process.

void do_command (const string &command, const string &params)
 Executes a single command as read from the .N file.

void build ()
 Builds all of the interrogate data.

void write_code (ostream &out, InterrogateModuleDef *def)
 Generates all the code necessary to the indicated output stream.

InterrogateModuleDefmake_module_def (int file_identifier)
 Allocates and returns a new InterrogateModuleDef structure that reflects the data we have just build, or at least that subset of the InterrogateModuleDef data that we have available at this time.

FunctionIndex get_destructor_for (CPPType *type)
 Returns the FunctionIndex for the destructor appropriate to destruct an instance of the indicated type, or 0 if no suitable destructor exists.

string get_preferred_name (CPPType *type)
 Returns the name of the type as it should be reported to the database.


Static Public Member Functions

string clean_identifier (const string &name)
 Adjusts the given string to remove any characters we don't want to export as part of an identifier name.

string descope (const string &name)
 Removes the leading "::", if present, from a fully-scoped name.

string hash_string (const string &name, int shift_offset)
 Hashes an arbitrary string into a four-character string using only the characters legal in a C identifier.


Private Types

typedef set< string > Commands
typedef map< string, string > CommandParams
typedef map< string, TypeIndexTypesByName
typedef map< string, FunctionIndexFunctionsByName
typedef map< string, char > IncludeFiles

Private Member Functions

void insert_param_list (InterrogateBuilder::Commands &commands, const string &params)
 Inserts a list of space-separated parameters into the given command parameter list.

bool in_forcetype (const string &name) const
 Returns true if the indicated name is one that the user identified with a forcetype command.

string in_renametype (const string &name) const
 If the user requested an explicit name for this type via the renametype command, returns that name; otherwise, returns the empty string.

bool in_ignoretype (const string &name) const
 Returns true if the indicated name is one that the user identified with an ignoretype command.

bool in_ignoreinvolved (const string &name) const
 Returns true if the indicated name is one that the user identified with an ignoreinvolved command.

bool in_ignoreinvolved (CPPType *type) const
 Returns true if the indicated type involves some type name that the user identified with an ignoreinvolved command.

bool in_ignorefile (const string &name) const
 Returns true if the indicated name is one that the user identified with an ignorefile command.

bool in_ignoremember (const string &name) const
 Returns true if the indicated name is one that the user identified with an ignoremember command.

bool in_noinclude (const string &name) const
 Returns true if the indicated filename is one that the user identified with a noinclude command.

bool should_include (const string &filename) const
 Returns true if the indicated filename is a valid file to explicitly #include in the generated .cxx file, false otherwise.

void remap_indices (vector< FunctionRemap * > &remaps)
 Resequences all of the index numbers so that function wrappers start at 1 and occupy consecutive positions, and everything else follows.

void scan_function (CPPFunctionGroup *fgroup)
 Adds the indicated global function to the database, if warranted.

void scan_function (CPPInstance *function)
 Adds the indicated global function to the database, if warranted.

void scan_struct_type (CPPStructType *type)
 Adds the indicated struct type to the database, if warranted.

void scan_enum_type (CPPEnumType *type)
 Adds the indicated enum type to the database, if warranted.

void scan_manifest (CPPManifest *manifest)
 Adds the indicated manifest constant to the database, if warranted.

ElementIndex scan_element (CPPInstance *element, CPPStructType *struct_type, CPPScope *scope)
 Adds the indicated data element to the database, if warranted.

FunctionIndex get_getter (CPPType *expr_type, string expression, CPPStructType *struct_type, CPPScope *scope, CPPInstance *element)
 Adds a function to return the value for the indicated expression.

FunctionIndex get_setter (CPPType *expr_type, string expression, CPPStructType *struct_type, CPPScope *scope, CPPInstance *element)
 Adds a function to return the value for the indicated expression.

FunctionIndex get_cast_function (CPPType *to_type, CPPType *from_type, const string &prefix)
 Adds a function to cast from a pointer of the indicated type to a pointer of the indicated type to the database.

FunctionIndex get_function (CPPInstance *function, string description, CPPStructType *struct_type, CPPScope *scope, int flags, const string &expression=string())
 Adds the indicated function to the database, if it is not already present.

TypeIndex get_atomic_string_type ()
 Returns a TypeIndex for the "atomic string" type, which is a bogus type that might be used if -string is passed to interrogate.

TypeIndex get_type (CPPType *type, bool global)
 Adds the indicated type to the database, if it is not already present.

void define_atomic_type (InterrogateType &itype, CPPSimpleType *cpptype)
 Builds up a definition for the indicated atomic type.

void define_wrapped_type (InterrogateType &itype, CPPPointerType *cpptype)
 Builds up a definition for the indicated wrapped type.

void define_wrapped_type (InterrogateType &itype, CPPConstType *cpptype)
 Builds up a definition for the indicated wrapped type.

void define_struct_type (InterrogateType &itype, CPPStructType *cpptype, TypeIndex type_index, bool forced)
 Builds up a definition for the indicated struct type.

void update_method_comment (CPPInstance *function, CPPStructType *struct_type, CPPScope *scope)
 Updates the method definition in the database to include whatever comment is associated with this declaration.

void define_method (CPPFunctionGroup *fgroup, InterrogateType &itype, CPPStructType *struct_type, CPPScope *scope)
 Adds the indicated member function to the struct type,.

void define_method (CPPInstance *function, InterrogateType &itype, CPPStructType *struct_type, CPPScope *scope)
 Adds the indicated member function to the struct type,.

void define_enum_type (InterrogateType &itype, CPPEnumType *cpptype)
 Builds up a definition for the indicated enum type.

void define_extension_type (InterrogateType &itype, CPPExtensionType *cpptype)
 Builds up a definition for the indicated extension type.


Static Private Member Functions

string trim_blanks (const string &str)

Private Attributes

TypesByName _types_by_name
FunctionsByName _functions_by_name
IncludeFiles _include_files
Commands _forcetype
CommandParams _renametype
Commands _ignoretype
Commands _ignoreinvolved
Commands _ignorefile
Commands _ignoremember
Commands _noinclude
string _library_hash_name

Friends

class FunctionRemap


Detailed Description

This class builds up the InterrogateDatabase based on the data indicated by CPPParser after reading the source code.

Definition at line 64 of file interrogateBuilder.h.


Member Typedef Documentation

typedef map<string, string> InterrogateBuilder::CommandParams [private]
 

Definition at line 82 of file interrogateBuilder.h.

typedef set<string> InterrogateBuilder::Commands [private]
 

Definition at line 81 of file interrogateBuilder.h.

typedef map<string, FunctionIndex> InterrogateBuilder::FunctionsByName [private]
 

Definition at line 139 of file interrogateBuilder.h.

typedef map<string, char> InterrogateBuilder::IncludeFiles [private]
 

Definition at line 144 of file interrogateBuilder.h.

typedef map<string, TypeIndex> InterrogateBuilder::TypesByName [private]
 

Definition at line 138 of file interrogateBuilder.h.


Member Function Documentation

void InterrogateBuilder::add_source_file const string &  filename  ) 
 

Adds the given source filename to the list of files that we are scanning.

Those source files that appear to be header files will be #included in the generated code file.

Definition at line 88 of file interrogateBuilder.cxx.

References size_t.

void InterrogateBuilder::build  ) 
 

Builds all of the interrogate data.

Definition at line 226 of file interrogateBuilder.cxx.

References _forcetype, and parser.

string InterrogateBuilder::clean_identifier const string &  name  )  [static]
 

Adjusts the given string to remove any characters we don't want to export as part of an identifier name.

Returns the cleaned string.

This replaces any consecutive invalid characters with an underscore.

Definition at line 577 of file interrogateBuilder.cxx.

References FunctionIndex, InterrogateType::get_destructor(), InterrogateDatabase::get_ptr(), InterrogateDatabase::get_type(), get_type(), and TypeIndex.

Referenced by get_getter(), and InterfaceMakerPythonObj::synthesize_this_parameter().

void InterrogateBuilder::define_atomic_type InterrogateType itype,
CPPSimpleType cpptype
[private]
 

Builds up a definition for the indicated atomic type.

Definition at line 1958 of file interrogateBuilder.cxx.

void InterrogateBuilder::define_enum_type InterrogateType itype,
CPPEnumType cpptype
[private]
 

Builds up a definition for the indicated enum type.

Definition at line 2454 of file interrogateBuilder.cxx.

void InterrogateBuilder::define_extension_type InterrogateType itype,
CPPExtensionType cpptype
[private]
 

Builds up a definition for the indicated extension type.

Definition at line 2512 of file interrogateBuilder.cxx.

void InterrogateBuilder::define_method CPPInstance function,
InterrogateType itype,
CPPStructType struct_type,
CPPScope scope
[private]
 

Adds the indicated member function to the struct type,.

Definition at line 2337 of file interrogateBuilder.cxx.

void InterrogateBuilder::define_method CPPFunctionGroup fgroup,
InterrogateType itype,
CPPStructType struct_type,
CPPScope scope
[private]
 

Adds the indicated member function to the struct type,.

Definition at line 2319 of file interrogateBuilder.cxx.

References InterrogateType::F_struct, InterrogateType::F_union, and CPPExtensionType::T_union.

void InterrogateBuilder::define_struct_type InterrogateType itype,
CPPStructType cpptype,
TypeIndex  type_index,
bool  forced
[private]
 

Builds up a definition for the indicated struct type.

Definition at line 2046 of file interrogateBuilder.cxx.

References InterrogateType::F_implicit_destructor.

void InterrogateBuilder::define_wrapped_type InterrogateType itype,
CPPConstType cpptype
[private]
 

Builds up a definition for the indicated wrapped type.

Definition at line 2032 of file interrogateBuilder.cxx.

void InterrogateBuilder::define_wrapped_type InterrogateType itype,
CPPPointerType cpptype
[private]
 

Builds up a definition for the indicated wrapped type.

Definition at line 2018 of file interrogateBuilder.cxx.

string InterrogateBuilder::descope const string &  name  )  [static]
 

Removes the leading "::", if present, from a fully-scoped name.

Sometimes CPPParser throws this on, and sometimes it doesn't.

Definition at line 611 of file interrogateBuilder.cxx.

void InterrogateBuilder::do_command const string &  command,
const string &  params
 

Executes a single command as read from the .N file.

Definition at line 158 of file interrogateBuilder.cxx.

References nout, and size_t.

TypeIndex InterrogateBuilder::get_atomic_string_type  )  [private]
 

Returns a TypeIndex for the "atomic string" type, which is a bogus type that might be used if -string is passed to interrogate.

It means to translate basic_string<char> and char * to whatever atomic string type is native to the particular the scripting language we happen to be generating wrappers for.

Definition at line 1785 of file interrogateBuilder.cxx.

References AT_char, AT_double, AT_float, AT_int, AT_not_atomic, AT_void, nout, CPPSimpleType::T_char, CPPSimpleType::T_double, CPPSimpleType::T_float, CPPSimpleType::T_int, and CPPSimpleType::T_void.

FunctionIndex InterrogateBuilder::get_cast_function CPPType to_type,
CPPType from_type,
const string &  prefix
[private]
 

Adds a function to cast from a pointer of the indicated type to a pointer of the indicated type to the database.

Returns the new function index.

Definition at line 1609 of file interrogateBuilder.cxx.

References InterrogateType::_atomic_token, InterrogateType::_flags, InterrogateType::_scoped_name, InterrogateType::_true_name, _types_by_name, InterrogateDatabase::add_type(), AT_string, InterrogateType::F_atomic, InterrogateDatabase::get_next_index(), InterrogateDatabase::get_ptr(), and TypeIndex.

FunctionIndex InterrogateBuilder::get_destructor_for CPPType type  ) 
 

Returns the FunctionIndex for the destructor appropriate to destruct an instance of the indicated type, or 0 if no suitable destructor exists.

Definition at line 631 of file interrogateBuilder.cxx.

FunctionIndex InterrogateBuilder::get_function CPPInstance function,
string  description,
CPPStructType struct_type,
CPPScope scope,
int  flags,
const string &  expression = string()
[private]
 

Adds the indicated function to the database, if it is not already present.

In either case, returns the FunctionIndex of the function within the database.

Definition at line 1680 of file interrogateBuilder.cxx.

References _types_by_name, and InterrogateType::F_global.

Referenced by get_getter().

FunctionIndex InterrogateBuilder::get_getter CPPType expr_type,
string  expression,
CPPStructType struct_type,
CPPScope scope,
CPPInstance element
[private]
 

Adds a function to return the value for the indicated expression.

Returns the new function index.

Definition at line 1440 of file interrogateBuilder.cxx.

References InterrogateFunction::_comment, CPPParameterList::_parameters, CPPDeclaration::as_struct_type(), clean_identifier(), InterrogateFunction::F_typecast, FunctionIndex, get_function(), get_preferred_name(), InterrogateDatabase::get_ptr(), CPPStructType::get_scope(), CPPType::new_type(), NULL, parser, ostringstream::str(), and InterrogateDatabase::update_function().

string InterrogateBuilder::get_preferred_name CPPType type  ) 
 

Returns the name of the type as it should be reported to the database.

This is either the name indicated by the user via a renametype command, or the "preferred name" of the type itself (i.e. the typedef name within the C++ code), or failing that, the type's true name.

Definition at line 659 of file interrogateBuilder.cxx.

Referenced by get_getter().

FunctionIndex InterrogateBuilder::get_setter CPPType expr_type,
string  expression,
CPPStructType struct_type,
CPPScope scope,
CPPInstance element
[private]
 

Adds a function to return the value for the indicated expression.

Returns the new function index.

Definition at line 1527 of file interrogateBuilder.cxx.

References CPPFunctionType::F_constructor, and NULL.

TypeIndex InterrogateBuilder::get_type CPPType type,
bool  global
[private]
 

Adds the indicated type to the database, if it is not already present.

In either case, returns the TypeIndex of the type within the database.

Definition at line 1826 of file interrogateBuilder.cxx.

Referenced by clean_identifier(), and scan_function().

string InterrogateBuilder::hash_string const string &  name,
int  shift_offset
[static]
 

Hashes an arbitrary string into a four-character string using only the characters legal in a C identifier.

Definition at line 681 of file interrogateBuilder.cxx.

References size_t.

bool InterrogateBuilder::in_forcetype const string &  name  )  const [private]
 

Returns true if the indicated name is one that the user identified with a forcetype command.

Definition at line 778 of file interrogateBuilder.cxx.

bool InterrogateBuilder::in_ignorefile const string &  name  )  const [private]
 

Returns true if the indicated name is one that the user identified with an ignorefile command.

Definition at line 905 of file interrogateBuilder.cxx.

References _functions_by_name.

Referenced by remap_indices(), and scan_function().

bool InterrogateBuilder::in_ignoreinvolved CPPType type  )  const [private]
 

Returns true if the indicated type involves some type name that the user identified with an ignoreinvolved command.

Definition at line 846 of file interrogateBuilder.cxx.

bool InterrogateBuilder::in_ignoreinvolved const string &  name  )  const [private]
 

Returns true if the indicated name is one that the user identified with an ignoreinvolved command.

Definition at line 830 of file interrogateBuilder.cxx.

References _noinclude.

Referenced by insert_param_list().

bool InterrogateBuilder::in_ignoremember const string &  name  )  const [private]
 

Returns true if the indicated name is one that the user identified with an ignoremember command.

Definition at line 920 of file interrogateBuilder.cxx.

References CPPFunctionGroup::_instances, and scan_function().

bool InterrogateBuilder::in_ignoretype const string &  name  )  const [private]
 

Returns true if the indicated name is one that the user identified with an ignoretype command.

Definition at line 815 of file interrogateBuilder.cxx.

References _ignoremember.

bool InterrogateBuilder::in_noinclude const string &  name  )  const [private]
 

Returns true if the indicated filename is one that the user identified with a noinclude command.

Definition at line 935 of file interrogateBuilder.cxx.

References CPPInstance::_type, CPPDeclaration::as_function_type(), CPPInstance::get_scope(), CPPInstance::is_scoped(), NULL, parser, and CPPType::resolve_type().

string InterrogateBuilder::in_renametype const string &  name  )  const [private]
 

If the user requested an explicit name for this type via the renametype command, returns that name; otherwise, returns the empty string.

Definition at line 795 of file interrogateBuilder.cxx.

void InterrogateBuilder::insert_param_list InterrogateBuilder::Commands commands,
const string &  params
[private]
 

Inserts a list of space-separated parameters into the given command parameter list.

Definition at line 749 of file interrogateBuilder.cxx.

References CPPArrayType::_element_type, CPPReferenceType::_pointing_at, CPPPointerType::_pointing_at, CPPDeclaration::as_array_type(), CPPDeclaration::as_const_type(), CPPDeclaration::as_pointer_type(), CPPDeclaration::as_reference_type(), CPPDeclaration::get_subtype(), in_ignoreinvolved(), CPPDeclaration::ST_array, CPPDeclaration::ST_const, CPPDeclaration::ST_pointer, and CPPDeclaration::ST_reference.

InterrogateModuleDef * InterrogateBuilder::make_module_def int  file_identifier  ) 
 

Allocates and returns a new InterrogateModuleDef structure that reflects the data we have just build, or at least that subset of the InterrogateModuleDef data that we have available at this time.

The data in this structure may include pointers that reference directly into the InterrogateBuilder object; thus, this structure is only valid for as long as the builder itself remains in scope.

Definition at line 543 of file interrogateBuilder.cxx.

void InterrogateBuilder::read_command_file istream &  in  ) 
 

Reads a .N file that might contain control information for the interrogate process.

Definition at line 107 of file interrogateBuilder.cxx.

void InterrogateBuilder::remap_indices vector< FunctionRemap * > &  remaps  )  [private]
 

Resequences all of the index numbers so that function wrappers start at 1 and occupy consecutive positions, and everything else follows.

This allows us to build a table of function wrappers by index number.

The "remaps" member is a list of FunctionRemap pointers. The collision in naming is unfortunate; the FunctionRemap objects are so named because they remap synthesized function wrappers to actual C++ methods and functions. It has nothing to do with the remapping of index numbers, which is the purpose of this function.

Definition at line 1017 of file interrogateBuilder.cxx.

References CPPScope::_declarations, CPPDeclaration::_file, CPPFile::_filename_as_referenced, CPPStructType::_scope, CPPFile::_source, CPPDeclaration::_vis, in_ignorefile(), CPPFile::is_c_file(), CPPDeclaration::is_template(), min_vis, NULL, and CPPFile::S_local.

ElementIndex InterrogateBuilder::scan_element CPPInstance element,
CPPStructType struct_type,
CPPScope scope
[private]
 

Adds the indicated data element to the database, if warranted.

Definition at line 1326 of file interrogateBuilder.cxx.

References CPPFunctionType::F_const_method, and InterrogateFunction::F_method.

void InterrogateBuilder::scan_enum_type CPPEnumType type  )  [private]
 

Adds the indicated enum type to the database, if warranted.

Definition at line 1210 of file interrogateBuilder.cxx.

References min_vis.

void InterrogateBuilder::scan_function CPPInstance function  )  [private]
 

Adds the indicated global function to the database, if warranted.

Definition at line 1070 of file interrogateBuilder.cxx.

References CPPDeclaration::_file, CPPFile::_filename_as_referenced, CPPFile::_source, CPPDeclaration::_vis, get_type(), in_ignorefile(), CPPFile::is_c_file(), CPPDeclaration::is_template(), min_vis, NULL, and CPPFile::S_local.

void InterrogateBuilder::scan_function CPPFunctionGroup fgroup  )  [private]
 

Adds the indicated global function to the database, if warranted.

Definition at line 1051 of file interrogateBuilder.cxx.

References min_vis.

Referenced by in_ignoremember().

void InterrogateBuilder::scan_manifest CPPManifest manifest  )  [private]
 

Adds the indicated manifest constant to the database, if warranted.

Definition at line 1252 of file interrogateBuilder.cxx.

References InterrogateElement::_flags, InterrogateElement::_getter, and InterrogateElement::F_has_getter.

void InterrogateBuilder::scan_struct_type CPPStructType type  )  [private]
 

Adds the indicated struct type to the database, if warranted.

Definition at line 1153 of file interrogateBuilder.cxx.

bool InterrogateBuilder::should_include const string &  filename  )  const [private]
 

Returns true if the indicated filename is a valid file to explicitly #include in the generated .cxx file, false otherwise.

Definition at line 952 of file interrogateBuilder.cxx.

References nout.

string InterrogateBuilder::trim_blanks const string &  str  )  [static, private]
 

Definition at line 2546 of file interrogateBuilder.cxx.

void InterrogateBuilder::update_method_comment CPPInstance function,
CPPStructType struct_type,
CPPScope scope
[private]
 

Updates the method definition in the database to include whatever comment is associated with this declaration.

This is called when we encounted a method definition outside of the class; the only new information this might include for us is the method comment.

Definition at line 2266 of file interrogateBuilder.cxx.

void InterrogateBuilder::write_code ostream &  out,
InterrogateModuleDef def
 

Generates all the code necessary to the indicated output stream.

Definition at line 320 of file interrogateBuilder.cxx.


Friends And Related Function Documentation

friend class FunctionRemap [friend]
 

Definition at line 157 of file interrogateBuilder.h.


Member Data Documentation

Commands InterrogateBuilder::_forcetype [private]
 

Definition at line 147 of file interrogateBuilder.h.

Referenced by build().

FunctionsByName InterrogateBuilder::_functions_by_name [private]
 

Definition at line 142 of file interrogateBuilder.h.

Referenced by in_ignorefile().

Commands InterrogateBuilder::_ignorefile [private]
 

Definition at line 151 of file interrogateBuilder.h.

Commands InterrogateBuilder::_ignoreinvolved [private]
 

Definition at line 150 of file interrogateBuilder.h.

Commands InterrogateBuilder::_ignoremember [private]
 

Definition at line 152 of file interrogateBuilder.h.

Referenced by in_ignoretype().

Commands InterrogateBuilder::_ignoretype [private]
 

Definition at line 149 of file interrogateBuilder.h.

IncludeFiles InterrogateBuilder::_include_files [private]
 

Definition at line 145 of file interrogateBuilder.h.

string InterrogateBuilder::_library_hash_name [private]
 

Definition at line 155 of file interrogateBuilder.h.

Commands InterrogateBuilder::_noinclude [private]
 

Definition at line 153 of file interrogateBuilder.h.

Referenced by in_ignoreinvolved().

CommandParams InterrogateBuilder::_renametype [private]
 

Definition at line 148 of file interrogateBuilder.h.

TypesByName InterrogateBuilder::_types_by_name [private]
 

Definition at line 141 of file interrogateBuilder.h.

Referenced by get_cast_function(), and get_function().


The documentation for this class was generated from the following files:
Generated on Thu May 1 22:13:36 2003 for DTool by doxygen1.3