in tools/make_cpptoc_impl.py [0:0]
def make_cpptoc_class_impl(header, clsname, impl):
# structure names that have already been defined
defined_names = header.get_defined_structs()
# retrieve the class and populate the defined names
cls = header.get_class(clsname, defined_names)
if cls is None:
raise Exception('Class does not exist: ' + clsname)
capiname = cls.get_capi_name()
prefixname = get_capi_name(clsname[3:], False)
# retrieve the existing virtual function implementations
existing = get_function_impls(impl, 'CEF_CALLBACK')
base_class_name = header.get_base_class_name(clsname)
base_scoped = True if base_class_name == 'CefBaseScoped' else False
if base_scoped:
template_class = 'CefCppToCScoped'
else:
template_class = 'CefCppToCRefCounted'
# generate virtual functions
virtualimpl = make_cpptoc_virtual_function_impl(
header, cls, existing, prefixname, defined_names, base_scoped)
if len(virtualimpl) > 0:
virtualimpl = '\nnamespace {\n\n// MEMBER FUNCTIONS - Body may be edited by hand.\n\n' + virtualimpl + '} // namespace'
# the current class is already defined for static functions
defined_names.append(cls.get_capi_name())
# retrieve the existing static function implementations
existing = get_function_impls(impl, 'CEF_EXPORT')
# generate static functions
staticimpl = make_cpptoc_function_impl(cls,
cls.get_static_funcs(), existing, None,
defined_names, base_scoped)
if len(staticimpl) > 0:
staticimpl = '\n// GLOBAL FUNCTIONS - Body may be edited by hand.\n\n' + staticimpl
resultingimpl = staticimpl + virtualimpl
# any derived classes can be unwrapped
unwrapderived = make_cpptoc_unwrap_derived(header, cls, base_scoped)
const = '// CONSTRUCTOR - Do not edit by hand.\n\n'+ \
clsname+'CppToC::'+clsname+'CppToC() {\n'
const += make_cpptoc_virtual_function_assignment(header, cls, prefixname,
defined_names)
const += '}\n\n'+ \
'// DESTRUCTOR - Do not edit by hand.\n\n'+ \
clsname+'CppToC::~'+clsname+'CppToC() {\n'
if not cls.has_attrib('no_debugct_check') and not base_scoped:
const += ' shutdown_checker::AssertNotShutdown();\n'
const += '}\n\n'
# determine what includes are required by identifying what translation
# classes are being used
includes = format_translation_includes(header, const + resultingimpl +
(unwrapderived[0]
if base_scoped else unwrapderived))
# build the final output
result = get_copyright()
result += includes + '\n' + resultingimpl + '\n'
parent_sig = template_class + '<' + clsname + 'CppToC, ' + clsname + ', ' + capiname + '>'
if base_scoped:
const += 'template<> CefOwnPtr<'+clsname+'> '+parent_sig+'::UnwrapDerivedOwn(CefWrapperType type, '+capiname+'* s) {\n' + \
unwrapderived[0] + \
' NOTREACHED() << "Unexpected class type: " << type;\n'+ \
' return CefOwnPtr<'+clsname+'>();\n'+ \
'}\n\n' + \
'template<> CefRawPtr<'+clsname+'> '+parent_sig+'::UnwrapDerivedRaw(CefWrapperType type, '+capiname+'* s) {\n' + \
unwrapderived[1] + \
' NOTREACHED() << "Unexpected class type: " << type;\n'+ \
' return nullptr;\n'+ \
'}\n\n'
else:
const += 'template<> CefRefPtr<'+clsname+'> '+parent_sig+'::UnwrapDerived(CefWrapperType type, '+capiname+'* s) {\n' + \
unwrapderived + \
' NOTREACHED() << "Unexpected class type: " << type;\n'+ \
' return nullptr;\n'+ \
'}\n\n'
const += 'template<> CefWrapperType ' + parent_sig + '::kWrapperType = ' + get_wrapper_type_enum(
clsname) + ';'
result += '\n\n' + const
return result