mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Break cef.h into multiple headers (issue #142).
- Move wrapper classes from cef_wrapper.h to wrapper/ directory. - Move C API functions/classes from cef_capi.h to capi/ directory. - Move global function implementations from cef_context.cc to *_impl.cc files. - Output auto-generated file paths in cef_paths.gypi. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@442 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
@@ -94,6 +94,10 @@ def wrap_code(code, indent = ' ', maxchars = 80, splitchars = '(=,'):
|
||||
|
||||
return output
|
||||
|
||||
def get_capi_file_name(cppname):
|
||||
""" Convert a C++ header file name to a C API header file name. """
|
||||
return cppname[:-2]+'_capi.h'
|
||||
|
||||
def get_capi_name(cppname, isclassname, prefix = None):
|
||||
""" Convert a C++ CamelCaps name to a C API underscore name. """
|
||||
result = ''
|
||||
@@ -193,7 +197,7 @@ def format_comment(comment, indent, translate_map = None, maxchars = 80):
|
||||
if didremovespace:
|
||||
result += ' '+line
|
||||
else:
|
||||
result += line;
|
||||
result += line
|
||||
result += '\n'
|
||||
else:
|
||||
# add to the current paragraph
|
||||
@@ -321,8 +325,12 @@ def dict_to_str(dict):
|
||||
str = []
|
||||
for name in dict.keys():
|
||||
if not isinstance(dict[name], list):
|
||||
# currently a string value
|
||||
str.append(name+'='+dict[name])
|
||||
if dict[name] is True:
|
||||
# currently a bool value
|
||||
str.append(name)
|
||||
else:
|
||||
# currently a string value
|
||||
str.append(name+'='+dict[name])
|
||||
else:
|
||||
# currently a list value
|
||||
for val in dict[name]:
|
||||
@@ -420,11 +428,26 @@ def get_copyright():
|
||||
class obj_header:
|
||||
""" Class representing a C++ header file. """
|
||||
|
||||
def __init__(self, filename):
|
||||
self.filename = filename;
|
||||
def __init__(self):
|
||||
self.filenames = []
|
||||
self.typedefs = []
|
||||
self.funcs = []
|
||||
self.classes = []
|
||||
|
||||
def add_directory(self, directory):
|
||||
""" Add all header files from the specified directory. """
|
||||
files = get_files(os.path.join(directory, '*.h'))
|
||||
for file in files:
|
||||
self.add_file(file)
|
||||
|
||||
def add_file(self, filepath):
|
||||
""" Add a header file. """
|
||||
|
||||
filename = os.path.split(filepath)[1]
|
||||
added = False
|
||||
|
||||
# read the input file into memory
|
||||
data = read_file(filename)
|
||||
data = read_file(filepath)
|
||||
|
||||
# remove space from between template definition end brackets
|
||||
data = data.replace("> >", ">>")
|
||||
@@ -434,23 +457,27 @@ class obj_header:
|
||||
_cre_space+_cre_cfname+';',
|
||||
re.MULTILINE | re.DOTALL)
|
||||
list = p.findall(data)
|
||||
|
||||
# build the global typedef objects
|
||||
self.typedefs = []
|
||||
for value, alias in list:
|
||||
self.typedefs.append(obj_typedef(self, value, alias))
|
||||
if len(list) > 0:
|
||||
# build the global typedef objects
|
||||
for value, alias in list:
|
||||
self.typedefs.append(obj_typedef(self, filename, value, alias))
|
||||
|
||||
# extract global functions
|
||||
p = re.compile('\n'+_cre_attrib+'\n'+_cre_func+'\((.*?)\)',
|
||||
re.MULTILINE | re.DOTALL)
|
||||
list = p.findall(data)
|
||||
if len(list) > 0:
|
||||
added = True
|
||||
|
||||
# build the global function objects
|
||||
for attrib, retval, argval in list:
|
||||
comment = get_comment(data, retval+'('+argval+');')
|
||||
self.funcs.append(obj_function(self, filename, attrib, retval,
|
||||
argval, comment))
|
||||
|
||||
# build the global function objects
|
||||
self.funcs = []
|
||||
for attrib, retval, argval in list:
|
||||
comment = get_comment(data, retval+'('+argval+');')
|
||||
self.funcs.append(obj_function(self, attrib, retval, argval,
|
||||
comment))
|
||||
# extract forward declarations
|
||||
p = re.compile('\nclass'+_cre_space+_cre_cfname+';')
|
||||
forward_declares = p.findall(data)
|
||||
|
||||
# extract classes
|
||||
p = re.compile('\n'+_cre_attrib+
|
||||
@@ -459,13 +486,19 @@ class obj_header:
|
||||
_cre_space+'CefBase'+
|
||||
'\n{(.*?)};', re.MULTILINE | re.DOTALL)
|
||||
list = p.findall(data)
|
||||
|
||||
# build the class objects
|
||||
self.classes = []
|
||||
for attrib, name, body in list:
|
||||
comment = get_comment(data, name+' : public virtual CefBase')
|
||||
self.classes.append(
|
||||
obj_class(self, attrib, name, body, comment))
|
||||
if len(list) > 0:
|
||||
added = True
|
||||
|
||||
# build the class objects
|
||||
for attrib, name, body in list:
|
||||
comment = get_comment(data, name+' : public virtual CefBase')
|
||||
self.classes.append(
|
||||
obj_class(self, filename, attrib, name, body, comment,
|
||||
forward_declares))
|
||||
|
||||
if added:
|
||||
# a global function or class was read from the header file
|
||||
self.filenames.append(filename)
|
||||
|
||||
def __repr__(self):
|
||||
result = ''
|
||||
@@ -490,21 +523,37 @@ class obj_header:
|
||||
|
||||
return result
|
||||
|
||||
def get_file_name(self):
|
||||
""" Return the file name. """
|
||||
return self.filename
|
||||
def get_file_names(self):
|
||||
""" Return the array of header file names. """
|
||||
return self.filenames
|
||||
|
||||
def get_typedefs(self):
|
||||
""" Return the array of typedef objects. """
|
||||
return self.typedefs
|
||||
|
||||
def get_funcs(self):
|
||||
def get_funcs(self, filename = None):
|
||||
""" Return the array of function objects. """
|
||||
return self.funcs
|
||||
if filename is None:
|
||||
return self.funcs
|
||||
else:
|
||||
# only return the functions in the specified file
|
||||
res = []
|
||||
for func in self.funcs:
|
||||
if func.get_file_name() == filename:
|
||||
res.append(func)
|
||||
return res
|
||||
|
||||
def get_classes(self):
|
||||
def get_classes(self, filename = None):
|
||||
""" Return the array of class objects. """
|
||||
return self.classes
|
||||
if filename is None:
|
||||
return self.classes
|
||||
else:
|
||||
# only return the classes in the specified file
|
||||
res = []
|
||||
for cls in self.classes:
|
||||
if cls.get_file_name() == filename:
|
||||
res.append(cls)
|
||||
return res
|
||||
|
||||
def get_class(self, classname, defined_structs = None):
|
||||
""" Return the specified class or None if not found. """
|
||||
@@ -544,8 +593,7 @@ class obj_header:
|
||||
|
||||
def get_defined_structs(self):
|
||||
""" Return a list of names already defined structure names. """
|
||||
return ['cef_print_info_t', 'cef_window_info_t',
|
||||
'cef_handler_menuinfo_t', 'cef_base_t']
|
||||
return ['cef_print_info_t', 'cef_window_info_t', 'cef_base_t']
|
||||
|
||||
def get_capi_translations(self):
|
||||
""" Return a dictionary that maps C++ terminology to C API terminology.
|
||||
@@ -585,14 +633,17 @@ class obj_header:
|
||||
class obj_class:
|
||||
""" Class representing a C++ class. """
|
||||
|
||||
def __init__(self, parent, attrib, name, body, comment):
|
||||
def __init__(self, parent, filename, attrib, name, body, comment,
|
||||
forward_declares):
|
||||
if not isinstance(parent, obj_header):
|
||||
raise Exception('Invalid parent object type')
|
||||
|
||||
self.parent = parent
|
||||
self.filename = filename
|
||||
self.attribs = str_to_dict(attrib)
|
||||
self.name = name
|
||||
self.comment = comment
|
||||
self.forward_declares = forward_declares
|
||||
|
||||
# extract typedefs
|
||||
p = re.compile('\n'+_cre_space+'typedef'+_cre_space+_cre_retval+
|
||||
@@ -603,7 +654,7 @@ class obj_class:
|
||||
# build the typedef objects
|
||||
self.typedefs = []
|
||||
for value, alias in list:
|
||||
self.typedefs.append(obj_typedef(self, value, alias))
|
||||
self.typedefs.append(obj_typedef(self, filename, value, alias))
|
||||
|
||||
# extract static functions
|
||||
p = re.compile('\n'+_cre_space+_cre_attrib+'\n'+_cre_space+'static'+
|
||||
@@ -659,9 +710,17 @@ class obj_class:
|
||||
result += "\n};\n"
|
||||
return result
|
||||
|
||||
def get_file_name(self):
|
||||
""" Return the C++ header file name. """
|
||||
return self.filename
|
||||
|
||||
def get_capi_file_name(self):
|
||||
""" Return the CAPI header file name. """
|
||||
return get_capi_file_name(self.filename)
|
||||
|
||||
def get_name(self):
|
||||
""" Return the class name. """
|
||||
return self.name;
|
||||
return self.name
|
||||
|
||||
def get_capi_name(self):
|
||||
""" Return the CAPI structure name for this class. """
|
||||
@@ -671,6 +730,11 @@ class obj_class:
|
||||
""" Return the class comment as an array of lines. """
|
||||
return self.comment
|
||||
|
||||
def get_forward_declares(self):
|
||||
""" Return the list of classes that are forward declared for this
|
||||
class. """
|
||||
return self.forward_declares
|
||||
|
||||
def get_attribs(self):
|
||||
""" Return all attributes as a dictionary. """
|
||||
return self.attribs
|
||||
@@ -688,7 +752,7 @@ class obj_class:
|
||||
else:
|
||||
# the value is a string
|
||||
return self.attribs[name]
|
||||
return None;
|
||||
return None
|
||||
|
||||
def get_attrib_list(self, name):
|
||||
""" Return all values for specified attribute as a list. """
|
||||
@@ -699,19 +763,19 @@ class obj_class:
|
||||
else:
|
||||
# convert the value to a list
|
||||
return [self.attribs[name]]
|
||||
return None;
|
||||
return None
|
||||
|
||||
def get_typedefs(self):
|
||||
""" Return the array of typedef objects. """
|
||||
return self.typedefs;
|
||||
return self.typedefs
|
||||
|
||||
def get_static_funcs(self):
|
||||
""" Return the array of static function objects. """
|
||||
return self.staticfuncs;
|
||||
return self.staticfuncs
|
||||
|
||||
def get_virtual_funcs(self):
|
||||
""" Return the array of virtual function objects. """
|
||||
return self.virtualfuncs;
|
||||
return self.virtualfuncs
|
||||
|
||||
def get_types(self, list):
|
||||
""" Return a dictionary mapping data types to analyzed values. """
|
||||
@@ -748,18 +812,27 @@ class obj_class:
|
||||
class obj_typedef:
|
||||
""" Class representing a typedef statement. """
|
||||
|
||||
def __init__(self, parent, value, alias):
|
||||
def __init__(self, parent, filename, value, alias):
|
||||
if not isinstance(parent, obj_header) \
|
||||
and not isinstance(parent, obj_class):
|
||||
raise Exception('Invalid parent object type')
|
||||
|
||||
self.parent = parent
|
||||
self.filename = filename
|
||||
self.alias = alias
|
||||
self.value = self.parent.get_analysis(value, False)
|
||||
|
||||
def __repr__(self):
|
||||
return 'typedef '+self.value.get_type()+' '+self.alias+';'
|
||||
|
||||
def get_file_name(self):
|
||||
""" Return the C++ header file name. """
|
||||
return self.filename
|
||||
|
||||
def get_capi_file_name(self):
|
||||
""" Return the CAPI header file name. """
|
||||
return get_capi_file_name(self.filename)
|
||||
|
||||
def get_alias(self):
|
||||
""" Return the alias. """
|
||||
return self.alias
|
||||
@@ -774,14 +847,15 @@ class obj_typedef:
|
||||
""" Return a dictionary mapping data types to analyzed values. """
|
||||
name = self.value.get_type()
|
||||
if not name in list:
|
||||
list[name] = self.value;
|
||||
list[name] = self.value
|
||||
|
||||
|
||||
class obj_function:
|
||||
""" Class representing a function. """
|
||||
|
||||
def __init__(self, parent, attrib, retval, argval, comment):
|
||||
def __init__(self, parent, filename, attrib, retval, argval, comment):
|
||||
self.parent = parent
|
||||
self.filename = filename
|
||||
self.attribs = str_to_dict(attrib)
|
||||
self.retval = obj_argument(self, retval)
|
||||
self.name = self.retval.remove_name()
|
||||
@@ -809,6 +883,14 @@ class obj_function:
|
||||
def __repr__(self):
|
||||
return '/* '+dict_to_str(self.attribs)+' */ '+self.get_cpp_proto()
|
||||
|
||||
def get_file_name(self):
|
||||
""" Return the C++ header file name. """
|
||||
return self.filename
|
||||
|
||||
def get_capi_file_name(self):
|
||||
""" Return the CAPI header file name. """
|
||||
return get_capi_file_name(self.filename)
|
||||
|
||||
def get_name(self):
|
||||
""" Return the function name. """
|
||||
return self.name
|
||||
@@ -849,7 +931,7 @@ class obj_function:
|
||||
else:
|
||||
# the value is a string
|
||||
return self.attribs[name]
|
||||
return None;
|
||||
return None
|
||||
|
||||
def get_attrib_list(self, name):
|
||||
""" Return all values for specified attribute as a list. """
|
||||
@@ -860,7 +942,7 @@ class obj_function:
|
||||
else:
|
||||
# convert the value to a list
|
||||
return [self.attribs[name]]
|
||||
return None;
|
||||
return None
|
||||
|
||||
def get_retval(self):
|
||||
""" Return the return value object. """
|
||||
@@ -977,7 +1059,8 @@ class obj_function_static(obj_function):
|
||||
def __init__(self, parent, attrib, retval, argval, comment):
|
||||
if not isinstance(parent, obj_class):
|
||||
raise Exception('Invalid parent object type')
|
||||
obj_function.__init__(self, parent, attrib, retval, argval, comment)
|
||||
obj_function.__init__(self, parent, parent.filename, attrib, retval,
|
||||
argval, comment)
|
||||
|
||||
def __repr__(self):
|
||||
return 'static '+obj_function.__repr__(self)+';'
|
||||
@@ -995,7 +1078,8 @@ class obj_function_virtual(obj_function):
|
||||
def __init__(self, parent, attrib, retval, argval, comment, vfmod):
|
||||
if not isinstance(parent, obj_class):
|
||||
raise Exception('Invalid parent object type')
|
||||
obj_function.__init__(self, parent, attrib, retval, argval, comment)
|
||||
obj_function.__init__(self, parent, parent.filename, attrib, retval,
|
||||
argval, comment)
|
||||
if vfmod == 'const':
|
||||
self.isconst = True
|
||||
else:
|
||||
@@ -1067,8 +1151,8 @@ class obj_argument:
|
||||
""" Returns the count function for this argument. """
|
||||
# The 'count_func' attribute value format is name:function
|
||||
if not self.parent.has_attrib('count_func'):
|
||||
return None;
|
||||
name = self.type.get_name();
|
||||
return None
|
||||
name = self.type.get_name()
|
||||
vals = self.parent.get_attrib_list('count_func')
|
||||
for val in vals:
|
||||
parts = string.split(val, ':')
|
||||
@@ -1193,7 +1277,7 @@ class obj_argument:
|
||||
return 'string_map_multi_byref_const'
|
||||
return 'string_map_multi_byref'
|
||||
|
||||
return 'invalid';
|
||||
return 'invalid'
|
||||
|
||||
def get_retval_type(self):
|
||||
""" Returns the retval type as defined in translator.README.txt. """
|
||||
@@ -1226,7 +1310,7 @@ class obj_argument:
|
||||
else:
|
||||
return 'refptr_diff'
|
||||
|
||||
return 'invalid';
|
||||
return 'invalid'
|
||||
|
||||
def get_retval_default(self, for_capi):
|
||||
""" Returns the default return value based on the retval type. """
|
||||
@@ -1239,7 +1323,7 @@ class obj_argument:
|
||||
return '1'
|
||||
if retval == 'false':
|
||||
return '0'
|
||||
return retval;
|
||||
return retval
|
||||
|
||||
# next look at the retval type value.
|
||||
type = self.get_retval_type()
|
||||
@@ -1678,7 +1762,7 @@ class obj_analysis:
|
||||
result += resdict['value']
|
||||
|
||||
if self.has_name():
|
||||
result += ' '+self.get_name();
|
||||
result += ' '+self.get_name()
|
||||
|
||||
return {'format' : format, 'value' : result}
|
||||
|
||||
@@ -1690,13 +1774,14 @@ if __name__ == "__main__":
|
||||
|
||||
# verify that the correct number of command-line arguments are provided
|
||||
if len(sys.argv) != 2:
|
||||
sys.stderr.write('Usage: '+sys.argv[0]+' <infile>')
|
||||
sys.stderr.write('Usage: '+sys.argv[0]+' <directory>')
|
||||
sys.exit()
|
||||
|
||||
pp = pprint.PrettyPrinter(indent=4)
|
||||
|
||||
# create the header object
|
||||
header = obj_header(sys.argv[1])
|
||||
header = obj_header()
|
||||
header.add_directory(sys.argv[1])
|
||||
|
||||
# output the type mapping
|
||||
types = {}
|
||||
|
@@ -14,7 +14,7 @@
|
||||
},
|
||||
'includes': [
|
||||
# Bring in the source file lists for cefclient.
|
||||
'cef_paths.gypi',
|
||||
'cef_paths2.gypi',
|
||||
],
|
||||
'targets': [
|
||||
{
|
||||
@@ -34,6 +34,7 @@
|
||||
],
|
||||
'sources': [
|
||||
'<@(includes_common)',
|
||||
'<@(includes_wrapper)',
|
||||
'<@(cefclient_sources_common)',
|
||||
],
|
||||
'mac_bundle_resources': [
|
||||
@@ -133,6 +134,8 @@
|
||||
],
|
||||
'sources': [
|
||||
'<@(includes_common)',
|
||||
'<@(includes_capi)',
|
||||
'<@(includes_wrapper)',
|
||||
'<@(libcef_dll_wrapper_sources_common)',
|
||||
],
|
||||
'xcode_settings': {
|
||||
|
@@ -37,7 +37,7 @@ def make_capi_member_funcs(funcs, defined_names, translate_map, indent):
|
||||
first = False
|
||||
return result
|
||||
|
||||
def make_capi_header(header):
|
||||
def make_capi_header(header, filename):
|
||||
# structure names that have already been defined
|
||||
defined_names = header.get_defined_structs()
|
||||
|
||||
@@ -82,64 +82,29 @@ def make_capi_header(header):
|
||||
// more information.
|
||||
//
|
||||
|
||||
#ifndef _CEF_CAPI_H
|
||||
#define _CEF_CAPI_H
|
||||
#ifndef $GUARD$
|
||||
#define $GUARD$
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "internal/cef_export.h"
|
||||
#include "internal/cef_string.h"
|
||||
#include "internal/cef_string_list.h"
|
||||
#include "internal/cef_string_map.h"
|
||||
#include "internal/cef_string_multimap.h"
|
||||
#include "internal/cef_types.h"
|
||||
#include "cef_base_capi.h"
|
||||
|
||||
"""
|
||||
# add the copyright year
|
||||
result = result.replace('$YEAR$', get_year())
|
||||
|
||||
# output global functions
|
||||
result += make_capi_global_funcs(header.get_funcs(), defined_names,
|
||||
translate_map, '')
|
||||
|
||||
# before classes string
|
||||
result += \
|
||||
"""
|
||||
typedef struct _cef_base_t
|
||||
{
|
||||
// Size of the data structure.
|
||||
size_t size;
|
||||
|
||||
// Increment the reference count.
|
||||
int (CEF_CALLBACK *add_ref)(struct _cef_base_t* self);
|
||||
// Decrement the reference count. Delete this object when no references
|
||||
// remain.
|
||||
int (CEF_CALLBACK *release)(struct _cef_base_t* self);
|
||||
// Returns the current number of references.
|
||||
int (CEF_CALLBACK *get_refct)(struct _cef_base_t* self);
|
||||
|
||||
} cef_base_t;
|
||||
|
||||
|
||||
// Check that the structure |s|, which is defined with a cef_base_t member named
|
||||
// |base|, is large enough to contain the specified member |f|.
|
||||
#define CEF_MEMBER_EXISTS(s, f) \\
|
||||
((intptr_t)&((s)->f) - (intptr_t)(s) + sizeof((s)->f) <= (s)->base.size)
|
||||
|
||||
#define CEF_MEMBER_MISSING(s, f) (!CEF_MEMBER_EXISTS(s, f) || !((s)->f))
|
||||
|
||||
"""
|
||||
funcs = header.get_funcs(filename)
|
||||
if len(funcs) > 0:
|
||||
result += make_capi_global_funcs(funcs, defined_names, translate_map, '')
|
||||
|
||||
# output classes
|
||||
classes = header.get_classes()
|
||||
classes = header.get_classes(filename)
|
||||
for cls in classes:
|
||||
# virtual functions are inside the structure
|
||||
classname = cls.get_capi_name()
|
||||
result += '\n'+format_comment(cls.get_comment(), '', translate_map);
|
||||
result += 'typedef struct _'+classname+ \
|
||||
'\n{\n // Base structure.\n cef_base_t base;\n'
|
||||
'\n{\n ///\n // Base structure.\n ///\n cef_base_t base;\n'
|
||||
funcs = cls.get_virtual_funcs()
|
||||
result += make_capi_member_funcs(funcs, defined_names,
|
||||
translate_map, ' ')
|
||||
@@ -160,23 +125,31 @@ typedef struct _cef_base_t
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _CEF_CAPI_H
|
||||
#endif // $GUARD$
|
||||
"""
|
||||
|
||||
# add the copyright year
|
||||
result = result.replace('$YEAR$', get_year())
|
||||
# add the guard string
|
||||
guard = '_'+string.upper(filename.replace('.', '_capi_'))
|
||||
result = result.replace('$GUARD$', guard)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def write_capi_header(header, file, backup):
|
||||
if path_exists(file):
|
||||
oldcontents = read_file(file)
|
||||
def write_capi_header(header, filepath, backup):
|
||||
capi_path = get_capi_file_name(filepath)
|
||||
if path_exists(capi_path):
|
||||
oldcontents = read_file(capi_path)
|
||||
else:
|
||||
oldcontents = ''
|
||||
|
||||
newcontents = make_capi_header(header)
|
||||
|
||||
filename = os.path.split(filepath)[1]
|
||||
newcontents = make_capi_header(header, filename)
|
||||
if newcontents != oldcontents:
|
||||
if backup and oldcontents != '':
|
||||
backup_file(file)
|
||||
write_file(file, newcontents)
|
||||
backup_file(capi_path)
|
||||
write_file(capi_path, newcontents)
|
||||
return True
|
||||
|
||||
return False
|
||||
@@ -192,7 +165,9 @@ if __name__ == "__main__":
|
||||
sys.exit()
|
||||
|
||||
# create the header object
|
||||
header = obj_header(sys.argv[1])
|
||||
header = obj_header()
|
||||
header.add_file(sys.argv[1])
|
||||
|
||||
# dump the result to stdout
|
||||
sys.stdout.write(make_capi_header(header))
|
||||
filename = os.path.split(sys.argv[1])[1]
|
||||
sys.stdout.write(make_capi_header(header, filename))
|
||||
|
@@ -12,7 +12,7 @@ set CPPDOC_REV="%1"
|
||||
if not exist %CPPDOC_EXE% (
|
||||
echo ERROR: Please install CppDoc from http://www.cppdoc.com/
|
||||
) else (
|
||||
%CPPDOC_EXE% -overwrite -title="CEF C++ API Docs - Revision %CPPDOC_REV%" -footer="<center><a href="http://code.google.com/p/chromiumembedded" target="_top">Chromium Embedded Framework (CEF)</a> Copyright © 2011 Marshall A. Greenblatt</center>" -namespace-as-project -comment-format="///;//;///" -classdir=projects -module="cppdoc-standard" -extensions=h -languages="c=cpp,cc=cpp,cpp=cpp,cs=csharp,cxx=cpp,h=cpp,hpp=cpp,hxx=cpp,java=java" -D"OS_WIN" -D"USING_CEF_SHARED" -D"__cplusplus" -D"CEF_STRING_TYPE_UTF16" -enable-author=false -enable-deprecations=true -enable-since=true -enable-version=false -file-links-for-globals=false -generate-deprecations-list=false -generate-hierarchy=true -header-background-dark="#ccccff" -header-background-light="#eeeeff" -include-private=false -include-protected=true -index-file-base=index -overview-html=overview.html -reduce-summary-font=true -selected-text-background=navy -selected-text-foreground=white -separate-index-pages=false -show-cppdoc-version=false -show-timestamp=false -summary-html=project.html -suppress-details=false -suppress-frames-links=false -table-background=white -wrap-long-lines=false ..\include #cef_capi.h #cef_nplugin_capi.h #cef_runnable.h #cef_tuple.h "..\docs\index.html"
|
||||
%CPPDOC_EXE% -overwrite -title="CEF C++ API Docs - Revision %CPPDOC_REV%" -footer="<center><a href="http://code.google.com/p/chromiumembedded" target="_top">Chromium Embedded Framework (CEF)</a> Copyright © 2011 Marshall A. Greenblatt</center>" -namespace-as-project -comment-format="///;//;///" -classdir=projects -module="cppdoc-standard" -extensions=h -languages="c=cpp,cc=cpp,cpp=cpp,cs=csharp,cxx=cpp,h=cpp,hpp=cpp,hxx=cpp,java=java" -D"OS_WIN" -D"USING_CEF_SHARED" -D"__cplusplus" -D"CEF_STRING_TYPE_UTF16" -enable-author=false -enable-deprecations=true -enable-since=true -enable-version=false -file-links-for-globals=false -generate-deprecations-list=false -generate-hierarchy=true -header-background-dark="#ccccff" -header-background-light="#eeeeff" -include-private=false -include-protected=true -index-file-base=index -overview-html=overview.html -reduce-summary-font=true -selected-text-background=navy -selected-text-foreground=white -separate-index-pages=false -show-cppdoc-version=false -show-timestamp=false -summary-html=project.html -suppress-details=false -suppress-frames-links=false -table-background=white -wrap-long-lines=false ..\include #cef_runnable.h #cef_tuple.h #capi "..\docs\index.html"
|
||||
)
|
||||
|
||||
endlocal
|
@@ -31,10 +31,19 @@ def make_cpptoc_header(header, clsname):
|
||||
#else // USING_CEF_SHARED
|
||||
"""
|
||||
|
||||
result += """
|
||||
#include "include/cef.h"
|
||||
#include "include/cef_capi.h"
|
||||
#include "libcef_dll/cpptoc/cpptoc.h"
|
||||
# include the headers for this class
|
||||
result += '\n#include "include/'+cls.get_file_name()+'"\n' \
|
||||
'#include "include/capi/'+cls.get_capi_file_name()+'"\n'
|
||||
|
||||
# include headers for any forward declared classes that are not in the same file
|
||||
declares = cls.get_forward_declares()
|
||||
for declare in declares:
|
||||
dcls = header.get_class(declare)
|
||||
if dcls.get_file_name() != cls.get_file_name():
|
||||
result += '#include "include/'+dcls.get_file_name()+'"\n' \
|
||||
'#include "include/capi/'+dcls.get_capi_file_name()+'"\n'
|
||||
|
||||
result += """#include "libcef_dll/cpptoc/cpptoc.h"
|
||||
|
||||
// Wrap a C++ class with a C structure.
|
||||
"""
|
||||
@@ -90,7 +99,8 @@ if __name__ == "__main__":
|
||||
sys.exit()
|
||||
|
||||
# create the header object
|
||||
header = obj_header(sys.argv[1])
|
||||
header = obj_header()
|
||||
header.add_file(sys.argv[1])
|
||||
|
||||
# dump the result to stdout
|
||||
sys.stdout.write(make_cpptoc_header(header, sys.argv[2]))
|
||||
|
@@ -24,7 +24,7 @@ def make_cpptoc_function_impl_existing(name, func, impl, defined_names):
|
||||
notify(name+' prototype changed')
|
||||
|
||||
return wrap_code(make_cpptoc_impl_proto(name, func, parts))+'{'+ \
|
||||
changes+impl['body']+'\n}\n\n'
|
||||
changes+impl['body']+'\n}\n'
|
||||
return result
|
||||
|
||||
def make_cpptoc_function_impl_new(name, func, defined_names):
|
||||
@@ -396,7 +396,7 @@ def make_cpptoc_function_impl_new(name, func, defined_names):
|
||||
if len(result) != result_len:
|
||||
result += '\n'
|
||||
|
||||
result += '}\n\n'
|
||||
result += '}\n'
|
||||
return wrap_code(result)
|
||||
|
||||
def make_cpptoc_function_impl(funcs, existing, prefixname, defined_names):
|
||||
@@ -489,10 +489,21 @@ def make_cpptoc_global_impl(header, impl):
|
||||
if len(impl) > 0:
|
||||
impl = '\n// GLOBAL FUNCTIONS - Body may be edited by hand.\n\n'+impl
|
||||
|
||||
includes = ''
|
||||
|
||||
# include required headers for global functions
|
||||
filenames = []
|
||||
for func in header.get_funcs():
|
||||
filename = func.get_file_name()
|
||||
if not filename in filenames:
|
||||
includes += '#include "include/'+func.get_file_name()+'"\n' \
|
||||
'#include "include/capi/'+func.get_capi_file_name()+'"\n'
|
||||
filenames.append(filename)
|
||||
|
||||
# determine what includes are required by identifying what translation
|
||||
# classes are being used
|
||||
includes = format_translation_includes(impl)
|
||||
|
||||
includes += format_translation_includes(impl)
|
||||
|
||||
# build the final output
|
||||
result = get_copyright()
|
||||
|
||||
@@ -536,7 +547,8 @@ if __name__ == "__main__":
|
||||
sys.exit()
|
||||
|
||||
# create the header object
|
||||
header = obj_header(sys.argv[1])
|
||||
header = obj_header()
|
||||
header.add_file(sys.argv[1])
|
||||
|
||||
# read the existing implementation file into memory
|
||||
try:
|
||||
@@ -548,4 +560,4 @@ if __name__ == "__main__":
|
||||
f.close()
|
||||
|
||||
# dump the result to stdout
|
||||
sys.stdout.write(make_cpptoc_impl(header, sys.argv[2], data))
|
||||
sys.stdout.write(make_cpptoc_class_impl(header, sys.argv[2], data))
|
||||
|
@@ -31,10 +31,19 @@ def make_ctocpp_header(header, clsname):
|
||||
#else // USING_CEF_SHARED
|
||||
"""
|
||||
|
||||
result += """
|
||||
#include "include/cef.h"
|
||||
#include "include/cef_capi.h"
|
||||
#include "libcef_dll/ctocpp/ctocpp.h"
|
||||
# include the headers for this class
|
||||
result += '\n#include "include/'+cls.get_file_name()+'"\n' \
|
||||
'#include "include/capi/'+cls.get_capi_file_name()+'"\n'
|
||||
|
||||
# include headers for any forward declared classes that are not in the same file
|
||||
declares = cls.get_forward_declares()
|
||||
for declare in declares:
|
||||
dcls = header.get_class(declare)
|
||||
if dcls.get_file_name() != cls.get_file_name():
|
||||
result += '#include "include/'+dcls.get_file_name()+'"\n' \
|
||||
'#include "include/capi/'+dcls.get_capi_file_name()+'"\n'
|
||||
|
||||
result += """#include "libcef_dll/ctocpp/ctocpp.h"
|
||||
|
||||
// Wrap a C structure with a C++ class.
|
||||
"""
|
||||
@@ -97,7 +106,8 @@ if __name__ == "__main__":
|
||||
sys.exit()
|
||||
|
||||
# create the header object
|
||||
header = obj_header(sys.argv[1])
|
||||
header = obj_header()
|
||||
header.add_file(sys.argv[1])
|
||||
|
||||
# dump the result to stdout
|
||||
sys.stdout.write(make_ctocpp_header(header, sys.argv[2]))
|
||||
|
@@ -32,7 +32,7 @@ def make_ctocpp_function_impl_existing(clsname, name, func, impl):
|
||||
notify(name+' prototype changed')
|
||||
|
||||
return wrap_code(make_ctocpp_impl_proto(clsname, name, func, parts))+'{'+ \
|
||||
changes+impl['body']+'\n}\n\n'
|
||||
changes+impl['body']+'\n}\n'
|
||||
|
||||
def make_ctocpp_function_impl_new(clsname, name, func):
|
||||
# build the C++ prototype
|
||||
@@ -430,7 +430,7 @@ def make_ctocpp_function_impl_new(clsname, name, func):
|
||||
if len(result) != result_len:
|
||||
result += '\n'
|
||||
|
||||
result += '}\n\n'
|
||||
result += '}\n'
|
||||
return wrap_code(result)
|
||||
|
||||
def make_ctocpp_function_impl(clsname, funcs, existing):
|
||||
@@ -496,11 +496,22 @@ def make_ctocpp_global_impl(header, impl):
|
||||
impl = make_ctocpp_function_impl(None, header.get_funcs(), existing)
|
||||
if len(impl) > 0:
|
||||
impl = '\n// GLOBAL METHODS - Body may be edited by hand.\n\n'+impl
|
||||
|
||||
|
||||
includes = ''
|
||||
|
||||
# include required headers for global functions
|
||||
filenames = []
|
||||
for func in header.get_funcs():
|
||||
filename = func.get_file_name()
|
||||
if not filename in filenames:
|
||||
includes += '#include "include/'+func.get_file_name()+'"\n' \
|
||||
'#include "include/capi/'+func.get_capi_file_name()+'"\n'
|
||||
filenames.append(filename)
|
||||
|
||||
# determine what includes are required by identifying what translation
|
||||
# classes are being used
|
||||
includes = format_translation_includes(impl)
|
||||
|
||||
includes += format_translation_includes(impl)
|
||||
|
||||
# build the final output
|
||||
result = get_copyright()
|
||||
|
||||
@@ -544,7 +555,8 @@ if __name__ == "__main__":
|
||||
sys.exit()
|
||||
|
||||
# create the header object
|
||||
header = obj_header(sys.argv[1])
|
||||
header = obj_header()
|
||||
header.add_file(sys.argv[1])
|
||||
|
||||
# read the existing implementation file into memory
|
||||
try:
|
||||
@@ -556,4 +568,4 @@ if __name__ == "__main__":
|
||||
f.close()
|
||||
|
||||
# dump the result to stdout
|
||||
sys.stdout.write(make_ctocpp_impl(header, sys.argv[2], data))
|
||||
sys.stdout.write(make_ctocpp_class_impl(header, sys.argv[2], data))
|
||||
|
@@ -50,6 +50,9 @@ def eval_file(src):
|
||||
def transfer_gypi_files(src_dir, gypi_paths, gypi_path_prefix, dst_dir, quiet):
|
||||
""" Transfer files from one location to another. """
|
||||
for path in gypi_paths:
|
||||
# skip gyp includes
|
||||
if path[:2] == '<@':
|
||||
continue
|
||||
src = os.path.join(src_dir, path)
|
||||
dst = os.path.join(dst_dir, path.replace(gypi_path_prefix, ''))
|
||||
dst_path = os.path.dirname(dst)
|
||||
@@ -200,10 +203,14 @@ make_dir(symbol_dir, options.quiet)
|
||||
# transfer the LICENSE.txt file
|
||||
copy_file(os.path.join(cef_dir, 'LICENSE.txt'), output_dir, options.quiet)
|
||||
|
||||
# read the variables list from cef_paths.gypi
|
||||
# read the variables list from the autogenerated cef_paths.gypi file
|
||||
cef_paths = eval_file(os.path.join(cef_dir, 'cef_paths.gypi'))
|
||||
cef_paths = cef_paths['variables']
|
||||
|
||||
# read the variables list from the manually edited cef_paths2.gypi file
|
||||
cef_paths2 = eval_file(os.path.join(cef_dir, 'cef_paths2.gypi'))
|
||||
cef_paths2 = cef_paths2['variables']
|
||||
|
||||
# create the include directory
|
||||
include_dir = os.path.join(output_dir, 'include')
|
||||
make_dir(include_dir, options.quiet)
|
||||
@@ -217,23 +224,35 @@ wrapper_dir = os.path.join(output_dir, 'libcef_dll')
|
||||
make_dir(wrapper_dir, options.quiet)
|
||||
|
||||
# transfer common include files
|
||||
transfer_gypi_files(cef_dir, cef_paths['includes_common'], \
|
||||
transfer_gypi_files(cef_dir, cef_paths2['includes_common'], \
|
||||
'include/', include_dir, options.quiet)
|
||||
transfer_gypi_files(cef_dir, cef_paths2['includes_capi'], \
|
||||
'include/', include_dir, options.quiet)
|
||||
transfer_gypi_files(cef_dir, cef_paths2['includes_wrapper'], \
|
||||
'include/', include_dir, options.quiet)
|
||||
transfer_gypi_files(cef_dir, cef_paths['autogen_cpp_includes'], \
|
||||
'include/', include_dir, options.quiet)
|
||||
transfer_gypi_files(cef_dir, cef_paths['autogen_capi_includes'], \
|
||||
'include/', include_dir, options.quiet)
|
||||
|
||||
# transfer common cefclient files
|
||||
transfer_gypi_files(cef_dir, cef_paths['cefclient_sources_common'], \
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_common'], \
|
||||
'tests/cefclient/', cefclient_dir, options.quiet)
|
||||
|
||||
# transfer common libcef_dll_wrapper files
|
||||
transfer_gypi_files(cef_dir, cef_paths['libcef_dll_wrapper_sources_common'], \
|
||||
transfer_gypi_files(cef_dir, cef_paths2['libcef_dll_wrapper_sources_common'], \
|
||||
'libcef_dll/', wrapper_dir, options.quiet)
|
||||
transfer_gypi_files(cef_dir, cef_paths['autogen_client_side'], \
|
||||
'libcef_dll/', wrapper_dir, options.quiet)
|
||||
|
||||
# transfer gyp files
|
||||
copy_file(os.path.join(script_dir, 'distrib/cefclient.gyp'), output_dir, options.quiet)
|
||||
paths_gypi = os.path.join(cef_dir, 'cef_paths.gypi')
|
||||
paths_gypi = os.path.join(cef_dir, 'cef_paths2.gypi')
|
||||
data = read_file(paths_gypi)
|
||||
data = data.replace('tests/cefclient/', 'cefclient/')
|
||||
write_file(os.path.join(output_dir, 'cef_paths.gypi'), data)
|
||||
write_file(os.path.join(output_dir, 'cef_paths2.gypi'), data)
|
||||
copy_file(os.path.join(cef_dir, 'cef_paths.gypi'), \
|
||||
os.path.join(output_dir, 'cef_paths.gypi'), options.quiet)
|
||||
|
||||
# transfer additional files
|
||||
transfer_files(cef_dir, script_dir, os.path.join(script_dir, 'distrib/transfer.cfg'), \
|
||||
@@ -245,11 +264,11 @@ if platform == 'windows':
|
||||
cef_rev, cef_ver, chromium_url, chromium_rev, chromium_ver, date)
|
||||
|
||||
# transfer include files
|
||||
transfer_gypi_files(cef_dir, cef_paths['includes_win'], \
|
||||
transfer_gypi_files(cef_dir, cef_paths2['includes_win'], \
|
||||
'include/', include_dir, options.quiet)
|
||||
|
||||
# transfer cefclient files
|
||||
transfer_gypi_files(cef_dir, cef_paths['cefclient_sources_win'], \
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_win'], \
|
||||
'tests/cefclient/', cefclient_dir, options.quiet)
|
||||
|
||||
# transfer build/Debug files
|
||||
@@ -316,11 +335,11 @@ elif platform == 'macosx':
|
||||
cef_rev, cef_ver, chromium_url, chromium_rev, chromium_ver, date)
|
||||
|
||||
# transfer include files
|
||||
transfer_gypi_files(cef_dir, cef_paths['includes_mac'], \
|
||||
transfer_gypi_files(cef_dir, cef_paths2['includes_mac'], \
|
||||
'include/', include_dir, options.quiet)
|
||||
|
||||
# transfer cefclient files
|
||||
transfer_gypi_files(cef_dir, cef_paths['cefclient_sources_mac'], \
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_mac'], \
|
||||
'tests/cefclient/', cefclient_dir, options.quiet)
|
||||
|
||||
# transfer cefclient/mac files
|
||||
@@ -403,11 +422,11 @@ elif platform == 'linux':
|
||||
sys.stderr.write("No Release build files.\n")
|
||||
|
||||
# transfer include files
|
||||
transfer_gypi_files(cef_dir, cef_paths['includes_linux'], \
|
||||
transfer_gypi_files(cef_dir, cef_paths2['includes_linux'], \
|
||||
'include/', include_dir, options.quiet)
|
||||
|
||||
# transfer cefclient files
|
||||
transfer_gypi_files(cef_dir, cef_paths['cefclient_sources_linux'], \
|
||||
transfer_gypi_files(cef_dir, cef_paths2['cefclient_sources_linux'], \
|
||||
'tests/cefclient/', cefclient_dir, options.quiet)
|
||||
|
||||
# transfer additional files, if any
|
||||
|
108
tools/make_gypi_file.py
Normal file
108
tools/make_gypi_file.py
Normal file
@@ -0,0 +1,108 @@
|
||||
# Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
|
||||
# reserved. Use of this source code is governed by a BSD-style license that
|
||||
# can be found in the LICENSE file.
|
||||
|
||||
from cef_parser import *
|
||||
|
||||
def make_gypi_file(header):
|
||||
# header string
|
||||
result = \
|
||||
"""# Copyright (c) $YEAR$ The Chromium Embedded Framework Authors. All rights
|
||||
# reserved. Use of this source code is governed by a BSD-style license that
|
||||
# can be found in the LICENSE file.
|
||||
#
|
||||
# ---------------------------------------------------------------------------
|
||||
#
|
||||
# This file was generated by the CEF translator tool and should not edited
|
||||
# by hand. See the translator.README.txt file in the tools directory for
|
||||
# more information.
|
||||
#
|
||||
|
||||
{
|
||||
'variables': {
|
||||
"""
|
||||
|
||||
filenames = sorted(header.get_file_names())
|
||||
|
||||
# cpp includes
|
||||
result += " 'autogen_cpp_includes': [\n"
|
||||
for filename in filenames:
|
||||
result += " 'include/"+filename+"',\n"
|
||||
result += " ],\n"
|
||||
|
||||
# capi includes
|
||||
result += " 'autogen_capi_includes': [\n"
|
||||
for filename in filenames:
|
||||
result += " 'include/capi/"+get_capi_file_name(filename)+"',\n"
|
||||
result += " ],\n"
|
||||
|
||||
classes = sorted(header.get_class_names())
|
||||
|
||||
# library side includes
|
||||
result += " 'autogen_library_side': [\n"
|
||||
for clsname in classes:
|
||||
cls = header.get_class(clsname)
|
||||
filename = get_capi_name(clsname[3:], False)
|
||||
if cls.is_library_side():
|
||||
result += " 'libcef_dll/cpptoc/"+filename+"_cpptoc.cc',\n" \
|
||||
" 'libcef_dll/cpptoc/"+filename+"_cpptoc.h',\n"
|
||||
else:
|
||||
result += " 'libcef_dll/ctocpp/"+filename+"_ctocpp.cc',\n" \
|
||||
" 'libcef_dll/ctocpp/"+filename+"_ctocpp.h',\n"
|
||||
result += " ],\n"
|
||||
|
||||
# client side includes
|
||||
result += " 'autogen_client_side': [\n"
|
||||
for clsname in classes:
|
||||
cls = header.get_class(clsname)
|
||||
filename = get_capi_name(clsname[3:], False)
|
||||
if cls.is_library_side():
|
||||
result += " 'libcef_dll/ctocpp/"+filename+"_ctocpp.cc',\n" \
|
||||
" 'libcef_dll/ctocpp/"+filename+"_ctocpp.h',\n"
|
||||
else:
|
||||
result += " 'libcef_dll/cpptoc/"+filename+"_cpptoc.cc',\n" \
|
||||
" 'libcef_dll/cpptoc/"+filename+"_cpptoc.h',\n"
|
||||
result += " ],\n"
|
||||
|
||||
# footer string
|
||||
result += \
|
||||
""" },
|
||||
}
|
||||
"""
|
||||
|
||||
# add the copyright year
|
||||
result = result.replace('$YEAR$', get_year())
|
||||
|
||||
return result
|
||||
|
||||
def write_gypi_file(header, file, backup):
|
||||
if path_exists(file):
|
||||
oldcontents = read_file(file)
|
||||
else:
|
||||
oldcontents = ''
|
||||
|
||||
newcontents = make_gypi_file(header)
|
||||
if newcontents != oldcontents:
|
||||
if backup and oldcontents != '':
|
||||
backup_file(file)
|
||||
write_file(file, newcontents)
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
# test the module
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
|
||||
# verify that the correct number of command-line arguments are provided
|
||||
if len(sys.argv) < 2:
|
||||
sys.stderr.write('Usage: '+sys.argv[0]+' <infile>')
|
||||
sys.exit()
|
||||
|
||||
# create the header object
|
||||
header = obj_header()
|
||||
header.add_file(sys.argv[1])
|
||||
|
||||
# dump the result to stdout
|
||||
sys.stdout.write(make_gypi_file(header))
|
@@ -1,3 +1,3 @@
|
||||
@echo off
|
||||
..\..\third_party\python_26\python.exe translator.py --cpp-header ..\include\cef.h --capi-header ..\include\cef_capi.h --cpptoc-global-impl ..\libcef_dll\libcef_dll.cc --ctocpp-global-impl ..\libcef_dll\wrapper\libcef_dll_wrapper.cc --cpptoc-dir ..\libcef_dll\cpptoc --ctocpp-dir ..\libcef_dll\ctocpp
|
||||
..\..\third_party\python_26\python.exe translator.py --cpp-header-dir ..\include --capi-header-dir ..\include\capi --cpptoc-global-impl ..\libcef_dll\libcef_dll.cc --ctocpp-global-impl ..\libcef_dll\wrapper\libcef_dll_wrapper.cc --cpptoc-dir ..\libcef_dll\cpptoc --ctocpp-dir ..\libcef_dll\ctocpp --gypi-file ..\cef_paths.gypi
|
||||
pause
|
@@ -9,6 +9,7 @@ from make_cpptoc_header import *
|
||||
from make_cpptoc_impl import *
|
||||
from make_ctocpp_header import *
|
||||
from make_ctocpp_impl import *
|
||||
from make_gypi_file import *
|
||||
from optparse import OptionParser
|
||||
|
||||
|
||||
@@ -24,10 +25,10 @@ This utility generates files for the CEF C++ to C API translation layer.
|
||||
"""
|
||||
|
||||
parser = OptionParser(description=disc)
|
||||
parser.add_option('--cpp-header', dest='cppheader', metavar='FILE',
|
||||
help='source CEF C++ header file [required]')
|
||||
parser.add_option('--capi-header', dest='capiheader', metavar='FILE',
|
||||
help='output CEF C API header file')
|
||||
parser.add_option('--cpp-header-dir', dest='cppheaderdir', metavar='DIR',
|
||||
help='input directory for C++ header files [required]')
|
||||
parser.add_option('--capi-header-dir', dest='capiheaderdir', metavar='DIR',
|
||||
help='output directory for C API header files')
|
||||
parser.add_option('--cpptoc-global-impl', dest='cpptocglobalimpl', metavar='FILE',
|
||||
help='input/output file for CppToC global translations')
|
||||
parser.add_option('--ctocpp-global-impl', dest='ctocppglobalimpl', metavar='FILE',
|
||||
@@ -36,6 +37,8 @@ parser.add_option('--cpptoc-dir', dest='cpptocdir', metavar='DIR',
|
||||
help='input/output directory for CppToC class translations')
|
||||
parser.add_option('--ctocpp-dir', dest='ctocppdir', metavar='DIR',
|
||||
help='input/output directory for CppToC class translations')
|
||||
parser.add_option('--gypi-file', dest='gypifile', metavar='FILE',
|
||||
help='output file for path information')
|
||||
parser.add_option('--no-cpptoc-header',
|
||||
action='store_true', dest='nocpptocheader', default=False,
|
||||
help='do not output the CppToC headers')
|
||||
@@ -59,28 +62,34 @@ parser.add_option('-q', '--quiet',
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
# the cppheader option is required
|
||||
if options.cppheader is None:
|
||||
if options.cppheaderdir is None:
|
||||
parser.print_help(sys.stdout)
|
||||
sys.exit()
|
||||
|
||||
# make sure the header exists
|
||||
if not path_exists(options.cppheader):
|
||||
sys.stderr.write('File '+options.cppheader+' does not exist.')
|
||||
if not path_exists(options.cppheaderdir):
|
||||
sys.stderr.write('File '+options.cppheaderdir+' does not exist.')
|
||||
sys.exit()
|
||||
|
||||
# create the header object
|
||||
if not options.quiet:
|
||||
sys.stdout.write('Parsing '+options.cppheader+'...\n')
|
||||
header = obj_header(options.cppheader)
|
||||
sys.stdout.write('Parsing C++ headers from '+options.cppheaderdir+'...\n')
|
||||
header = obj_header()
|
||||
header.add_directory(options.cppheaderdir)
|
||||
|
||||
writect = 0
|
||||
|
||||
if not options.capiheader is None:
|
||||
if not options.capiheaderdir is None:
|
||||
#output the C API header
|
||||
if not options.quiet:
|
||||
sys.stdout.write('Generating C API header...\n')
|
||||
writect += write_capi_header(header, options.capiheader,
|
||||
not options.nobackup)
|
||||
sys.stdout.write('In C API header directory '+options.capiheaderdir+'...\n')
|
||||
filenames = sorted(header.get_file_names())
|
||||
for filename in filenames:
|
||||
if not options.quiet:
|
||||
sys.stdout.write('Generating '+filename+' C API header...\n')
|
||||
writect += write_capi_header(header,
|
||||
os.path.join(options.capiheaderdir, filename),
|
||||
not options.nobackup)
|
||||
|
||||
# build the list of classes to parse
|
||||
allclasses = header.get_class_names()
|
||||
@@ -110,7 +119,7 @@ if not options.ctocppglobalimpl is None:
|
||||
not options.nobackup)
|
||||
|
||||
if not options.cpptocdir is None:
|
||||
#output CppToC class files
|
||||
# output CppToC class files
|
||||
if not options.quiet:
|
||||
sys.stdout.write('In CppToC directory '+options.cpptocdir+'...\n')
|
||||
|
||||
@@ -127,7 +136,7 @@ if not options.cpptocdir is None:
|
||||
not options.nobackup)
|
||||
|
||||
if not options.ctocppdir is None:
|
||||
#output CppToC class files
|
||||
# output CppToC class files
|
||||
if not options.quiet:
|
||||
sys.stdout.write('In CToCpp directory '+options.ctocppdir+'...\n')
|
||||
for cls in classes:
|
||||
@@ -142,6 +151,12 @@ if not options.ctocppdir is None:
|
||||
writect += write_ctocpp_impl(header, cls, options.ctocppdir,
|
||||
not options.nobackup)
|
||||
|
||||
if not options.gypifile is None:
|
||||
# output the gypi file
|
||||
if not options.quiet:
|
||||
sys.stdout.write('Generating '+options.gypifile+' file...\n')
|
||||
writect += write_gypi_file(header, options.gypifile, not options.nobackup)
|
||||
|
||||
if not options.quiet:
|
||||
sys.stdout.write('Done - Wrote '+str(writect)+' files.\n')
|
||||
|
||||
|
@@ -1,2 +1,2 @@
|
||||
#!/bin/sh
|
||||
python translator.py --cpp-header ../include/cef.h --capi-header ../include/cef_capi.h --cpptoc-global-impl ../libcef_dll/libcef_dll.cc --ctocpp-global-impl ../libcef_dll/wrapper/libcef_dll_wrapper.cc --cpptoc-dir ../libcef_dll/cpptoc --ctocpp-dir ../libcef_dll/ctocpp
|
||||
python translator.py --cpp-header-dir ../include --capi-header-dir ../include/capi --cpptoc-global-impl ../libcef_dll/libcef_dll.cc --ctocpp-global-impl ../libcef_dll/wrapper/libcef_dll_wrapper.cc --cpptoc-dir ../libcef_dll/cpptoc --ctocpp-dir ../libcef_dll/ctocpp --gypi-file ../cef_paths.gypi
|
||||
|
Reference in New Issue
Block a user