original_docstring: Writes the Pepper OpenGLES interface implementation.
docstring: Writes the Pepper OpenGLES interface implementation.
docstring_tokens: Writes the Pepper OpenGLES interface implementation .
code: def WritePepperGLES2Implementation(self, filename):
      """Writes the Pepper OpenGLES interface implementation."""
  
      file = CWriter(filename)
      file.Write(_LICENSE)
      file.Write(_DO_NOT_EDIT_WARNING)
  
      file.Write("#include \"ppapi/shared_impl/ppb_opengles2_shared.h\"\n\n")
      file.Write("#include \"base/logging.h\"\n")
      file.Write("#include \"gpu/command_buffer/client/gles2_implementation.h\"\n")
      file.Write("#include \"ppapi/shared_impl/ppb_graphics_3d_shared.h\"\n")
      file.Write("#include \"ppapi/thunk/enter.h\"\n\n")
  
      file.Write("namespace ppapi {\n\n")
      file.Write("namespace {\n\n")
  
      file.Write("typedef thunk::EnterResource<thunk::PPB_Graphics3D_API>"
                 " Enter3D;\n\n")
  
      file.Write("gpu::gles2::GLES2Implementation* ToGles2Impl(Enter3D*"
                 " enter) {\n")
      file.Write("  DCHECK(enter);\n")
      file.Write("  DCHECK(enter->succeeded());\n")
      file.Write("  return static_cast<PPB_Graphics3D_Shared*>(enter->object())->"
                 "gles2_impl();\n");
      file.Write("}\n\n");
  
      for func in self.original_functions:
        if not func.InAnyPepperExtension():
          continue
  
        original_arg = func.MakeTypedPepperArgString("")
        context_arg = "PP_Resource context_id"
        if len(original_arg):
          arg = context_arg + ", " + original_arg
        else:
          arg = context_arg
        file.Write("%s %s(%s) {\n" %
                   (func.return_type, func.GetPepperName(), arg))
        file.Write("  Enter3D enter(context_id, true);\n")
        file.Write("  if (enter.succeeded()) {\n")
  
        return_str = "" if func.return_type == "void" else "return "
        file.Write("    %sToGles2Impl(&enter)->%s(%s);\n" %
                   (return_str, func.original_name,
                    func.MakeOriginalArgString("")))
        file.Write("  }")
        if func.return_type == "void":
          file.Write("\n")
        else:
          file.Write(" else {\n")
          file.Write("    return %s;\n" % func.GetErrorReturnString())
          file.Write("  }\n")
        file.Write("}\n\n")
  
      file.Write("}  // namespace\n")
  
      for interface in self.pepper_interfaces:
        file.Write("const %s* PPB_OpenGLES2_Shared::Get%sInterface() {\n" %
                   (interface.GetStructName(), interface.GetName()))
        file.Write("  static const struct %s "
                   "ppb_opengles2 = {\n" % interface.GetStructName())
        file.Write("    &")
        file.Write(",\n    &".join(
          f.GetPepperName() for f in self.original_functions
            if f.InPepperInterface(interface)))
        file.Write("\n")
  
        file.Write("  };\n")
        file.Write("  return &ppb_opengles2;\n")
        file.Write("}\n")
  
      file.Write("}  // namespace ppapi\n")
      file.Close()
      self.generated_cpp_filenames.append(file.filename)
code_tokens: def WritePepperGLES2Implementation ( self , filename ) : file = CWriter ( filename ) file . Write ( _LICENSE ) file . Write ( _DO_NOT_EDIT_WARNING ) file . Write ( "#include \"ppapi/shared_impl/ppb_opengles2_shared.h\"\n\n" ) file . Write ( "#include \"base/logging.h\"\n" ) file . Write ( "#include \"gpu/command_buffer/client/gles2_implementation.h\"\n" ) file . Write ( "#include \"ppapi/shared_impl/ppb_graphics_3d_shared.h\"\n" ) file . Write ( "#include \"ppapi/thunk/enter.h\"\n\n" ) file . Write ( "namespace ppapi {\n\n" ) file . Write ( "namespace {\n\n" ) file . Write ( "typedef thunk::EnterResource<thunk::PPB_Graphics3D_API>" " Enter3D;\n\n" ) file . Write ( "gpu::gles2::GLES2Implementation* ToGles2Impl(Enter3D*" " enter) {\n" ) file . Write ( "  DCHECK(enter);\n" ) file . Write ( "  DCHECK(enter->succeeded());\n" ) file . Write ( "  return static_cast<PPB_Graphics3D_Shared*>(enter->object())->" "gles2_impl();\n" ) ; file . Write ( "}\n\n" ) ; for func in self . original_functions : if not func . InAnyPepperExtension ( ) : continue original_arg = func . MakeTypedPepperArgString ( "" ) context_arg = "PP_Resource context_id" if len ( original_arg ) : arg = context_arg + ", " + original_arg else : arg = context_arg file . Write ( "%s %s(%s) {\n" % ( func . return_type , func . GetPepperName ( ) , arg ) ) file . Write ( "  Enter3D enter(context_id, true);\n" ) file . Write ( "  if (enter.succeeded()) {\n" ) return_str = "" if func . return_type == "void" else "return " file . Write ( "    %sToGles2Impl(&enter)->%s(%s);\n" % ( return_str , func . original_name , func . MakeOriginalArgString ( "" ) ) ) file . Write ( "  }" ) if func . return_type == "void" : file . Write ( "\n" ) else : file . Write ( " else {\n" ) file . Write ( "    return %s;\n" % func . GetErrorReturnString ( ) ) file . Write ( "  }\n" ) file . Write ( "}\n\n" ) file . Write ( "}  // namespace\n" ) for interface in self . pepper_interfaces : file . Write ( "const %s* PPB_OpenGLES2_Shared::Get%sInterface() {\n" % ( interface . GetStructName ( ) , interface . GetName ( ) ) ) file . Write ( "  static const struct %s " "ppb_opengles2 = {\n" % interface . GetStructName ( ) ) file . Write ( "    &" ) file . Write ( ",\n    &" . join ( f . GetPepperName ( ) for f in self . original_functions if f . InPepperInterface ( interface ) ) ) file . Write ( "\n" ) file . Write ( "  };\n" ) file . Write ( "  return &ppb_opengles2;\n" ) file . Write ( "}\n" ) file . Write ( "}  // namespace ppapi\n" ) file . Close ( ) self . generated_cpp_filenames . append ( file . filename )
short_docstring: Writes the Pepper OpenGLES interface implementation.
short_docstring_tokens: Writes the Pepper OpenGLES interface implementation .
comment: """Writes the Pepper OpenGLES interface implementation."""