def PpapiBindingGlueCpp(scope, type_defn): """Gets the PPAPI glue implementation for a given type. Args: scope: a Definition for the scope in which the glue will be written. type_defn: a Definition, representing the type. Returns: a string, the glue implementation. """ glue_class = type_defn.name + '_glue' run_function, unused_check = cpp_utils.GetFunctionPrototype( scope, _MakeRunFunction(scope, type_defn), glue_class + '::') if 'async' in type_defn.attributes: async_param = 'true' else: async_param = 'false' callback_glue = 'return RunCallback(instance_, object_, %s' % async_param if type_defn.params: callback_glue += ', '.join([''] + [t.name for t in type_defn.params]) callback_glue += ')' return _ppapi_binding_glue_cpp_template.substitute( GlueClass=glue_class, RunFunction=run_function, CallbackGlue=callback_glue)
def Function(self, parent_section, scope, obj): """Generates the code for a Function definition. Args: parent_section: the main section of the parent scope. scope: the parent scope. obj: the Function definition. Returns: a list of (boolean, Definition) pairs, of all the types that need to be declared (boolean is False) or defined (boolean is True) before this definition. """ section = self.GetSectionFromAttributes(parent_section, obj) self.Documentation(section, scope, obj) # create temporary function for generating Java syntax func_name = naming.Normalize(obj.name, naming.Java) function = syntax_tree.Function(obj.source, obj.attributes, func_name, None, []) function.type_defn = obj.type_defn function.parent = obj.parent function.params = obj.params prototype, check_types = cpp_utils.GetFunctionPrototype( scope, function, '') section.EmitCode(prototype + ';') return check_types
def PpapiBindingGlueHeader(scope, type_defn): """Gets the PPAPI glue header for a given type. Args: scope: a Definition for the scope in which the glue will be written. type_defn: a Definition, representing the type. Returns: a string, the glue header. """ glue_class = type_defn.name + '_glue' base_class = cpp_utils.GetScopedName(scope, type_defn) run_function, unused_check = cpp_utils.GetFunctionPrototype( scope, _MakeRunFunction(scope, type_defn), '') return _ppapi_binding_glue_header_template.substitute( GlueClass=glue_class, BaseClass=base_class, RunFunction=run_function)