Ejemplo n.º 1
0
 def __init__(self, name, sname, desc):
   self.name = name
   self.run_switch = Option(sname, desc)
   self.opt_switch = Option(sname + '_opt', 'Options for %s.' % sname,
                            default='')
   GeneratorList.append(self)
   self.errors = 0
   self.skip_list = []
Ejemplo n.º 2
0
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""
IDLNamespace for PPAPI

This file defines the behavior of the AST namespace which allows for resolving
a symbol as one or more AST nodes given a release or range of releases.
"""

import sys

from idl_option import GetOption, Option, ParseOptions
from idl_log import ErrOut, InfoOut, WarnOut
from idl_release import IDLRelease, IDLReleaseList

Option('label', 'Use the specifed label blocks.', default='Chrome')
Option('namespace_debug', 'Use the specified release')


#
# IDLNamespace
#
# IDLNamespace provides a mapping between a symbol name and an IDLReleaseList
# which contains IDLRelease objects.  It provides an interface for fetching
# one or more IDLNodes based on a release or range of releases.
#
class IDLNamespace(object):
    def __init__(self, parent):
        self.namespace = {}
        self.parent = parent
Ejemplo n.º 3
0
between GCC and PNaCl.  """

from datetime import datetime
import difflib
import glob
import os
import sys

from idl_c_proto import CGen
from idl_gen_wrapper import Interface, WrapperGen
from idl_log import ErrOut, InfoOut, WarnOut
from idl_option import GetOption, Option, ParseOptions
from idl_parser import ParseFiles

Option('pnaclshim',
       'Name of the pnacl shim file.',
       default='temp_pnacl_shim.c')

Option('disable_pnacl_opt', 'Turn off optimization of pnacl shim.')


class PnaclGen(WrapperGen):
    """PnaclGen generates shim code to bridge the Gcc ABI with PNaCl.

  This subclass of WrapperGenerator takes the IDL sources and
  generates shim methods for bridging the calling conventions between GCC
  and PNaCl (LLVM). Some of the PPAPI methods do not need shimming, so
  this will also detect those situations and provide direct access to the
  original PPAPI methods (rather than the shim methods).
  """
    def __init__(self):
Ejemplo n.º 4
0
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
""" Lint for IDL """

import os
import sys

from idl_log import ErrOut, InfoOut, WarnOut
from idl_node import IDLAttribute, IDLNode
from idl_ast import IDLAst
from idl_option import GetOption, Option, ParseOptions
from idl_outfile import IDLOutFile
from idl_visitor import IDLVisitor

Option('wcomment', 'Disable warning for missing comment.')
Option('wenum', 'Disable warning for missing enum value.')
Option('winline', 'Disable warning for inline blocks.')
Option('wname', 'Disable warning for inconsistent interface name.')
Option('wnone', 'Disable all warnings.')
Option('wparam', 'Disable warning for missing [in|out|inout] on param.')
Option('wpass', 'Disable warning for mixed passByValue and returnByValue.')


#
# IDLLinter
#
# Once the AST is build, we need to resolve the namespace and version
# information.
#
class IDLLinter(IDLVisitor):
Ejemplo n.º 5
0
between C# and the C++ PepperPlugin interface.  """

from datetime import datetime
import difflib
import glob
import os
import sys

from idl_c_proto import CGen
from idl_gen_wrapper import Interface, WrapperGen
from idl_log import ErrOut, InfoOut, WarnOut
from idl_option import GetOption, Option, ParseOptions
from idl_parser import ParseFiles

Option('pepperfile',
       'Name of the pepper file.',
       default='../pepper/pepper_entrypoints.cpp ')

Option('disable_pepper_opt', 'Turn off optimization of pepper.')
Option('disable_region_gen', 'Turn off #pragma region generation.')

# Remap default values
RemapDefaultValue = {
    'PP_Bool': 'PP_FromBool(false)',
    'void': '',
    'PP_ImageDataFormat': 'PP_IMAGEDATAFORMAT_BGRA_PREMUL',
    'PP_InputEvent_MouseButton': 'PP_INPUTEVENT_MOUSEBUTTON_NONE',
    'PP_InputEvent_Type': 'PP_INPUTEVENT_TYPE_UNDEFINED',
    'PP_FloatPoint': 'PP_MakeFloatPoint(0,0)',
    'struct PP_FloatPoint': 'PP_MakeFloatPoint(0,0)',
    'PP_Point': 'PP_MakePoint(0,0)',
Ejemplo n.º 6
0
import glob
import os
import re
import sys

from idl_log import ErrOut, InfoOut, WarnOut
from idl_node import IDLAttribute, IDLNode
from idl_ast import IDLAst
from idl_option import GetOption, Option, ParseOptions
from idl_outfile import IDLOutFile
from idl_parser import ParseFiles
from idl_c_proto import CGen, GetNodeComments, CommentLines, Comment
from idl_generator import Generator, GeneratorByFile
from idl_visitor import IDLVisitor

Option('dstroot', 'Base directory of output', default=os.path.join('..', 'c'))
Option('guard', 'Include guard prefix', default=os.path.join('ppapi', 'c'))


#
# PrototypeResolver
#
# A specialized visitor which traverses the AST, building a mapping of
# Release names to Versions numbers and calculating a min version.
# The mapping is applied to the File nodes within the AST.
#
class ProtoResolver(IDLVisitor):
    def __init__(self):
        IDLVisitor.__init__(self)
        self.struct_map = {}
        self.interface_map = {}
Ejemplo n.º 7
0
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
""" Generator for C-Sharp style binding definitions """

import glob
import os
import sys
import string

from idl_log import ErrOut, InfoOut, WarnOut
from idl_node import IDLNode
from idl_ast import IDLAst
from idl_option import GetOption, Option, ParseOptions
from idl_parser import ParseFiles

Option('csgen_debug', 'Debug generate.')
Option('cs-enum_prefix', 'Suppress the enum prefix when generating.')


class CGenError(Exception):
    def __init__(self, msg):
        self.value = msg

    def __str__(self):
        return repr(self.value)


def CommentLines(lines, tabs=0):
    # Generate a C style comment block by prepending the block with '<tab>/*'
    # and adding a '<tab> *' per line.
    tab = '  ' * tabs
Ejemplo n.º 8
0
import glob
import os
import re
import sys

from idl_log import ErrOut, InfoOut, WarnOut
from idl_node import IDLAttribute, IDLNode
from idl_ast import IDLAst
from idl_option import GetOption, Option, ParseOptions
from idl_outfile import IDLOutFile
from idl_parser import ParseFiles
from idl_c_proto import CGen, GetNodeComments, CommentLines, Comment
from idl_generator import Generator, GeneratorByFile

Option('thunkroot', 'Base directory of output',
       default=os.path.join('..', 'thunk'))


class TGenError(Exception):
  def __init__(self, msg):
    self.value = msg

  def __str__(self):
    return repr(self.value)


class ThunkBodyMetadata(object):
  """Metadata about thunk body. Used for selecting which headers to emit."""
  def __init__(self):
    self._apis = set()
    self._includes = set()
Ejemplo n.º 9
0
#!/usr/bin/env python
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import sys

from idl_log import ErrOut, InfoOut, WarnOut
from idl_option import GetOption, Option, ParseOptions
from idl_parser import ParseFiles

GeneratorList = []

Option('out', 'List of output files', default='')
Option('release', 'Which release to generate.', default='')
Option('range', 'Which ranges in the form of MIN,MAX.', default='start,end')


class Generator(object):
    """Base class for generators.

  This class provides a mechanism for adding new generator objects to the IDL
  driver.  To use this class override the GenerateRelease and GenerateRange
  members, and instantiate one copy of the class in the same module which
  defines it to register the generator.  After the AST is generated, call the
  static Run member which will check every registered generator to see which
  ones have been enabled through command-line options.  To enable a generator
  use the switches:
    --<sname> : To enable with defaults
    --<sname>_opt=<XXX,YYY=y> : To enable with generator specific options.
Ejemplo n.º 10
0
import glob
import os
import re
import sys

from idl_log import ErrOut, InfoOut, WarnOut
from idl_node import IDLNode
from idl_ast import IDLAst
from idl_option import GetOption, Option, ParseOptions
from idl_parser import ParseFiles
from idl_c_proto import CGen
from idl_c_header import GetHeaderFromNode, GenerateHeader
from idl_outfile import IDLOutFile

Option('debug', 'Debug generate.')

#API = namedtuple('API', ['interface', 'member', 'param'])

customAPIs = {
    ('PPB_CharSet_Dev', 'CharSetToUTF16', 'input'): {
        'array': True,
        'arrayType': 'uint8_t',
        'arraySize': 'input_len'
    },
    ('PPB_CharSet_Dev', 'CharSetToUTF16', 'rval'): {
        'convert':
        '  size_t length = iterator.expectArrayAndGotoFirstItem();\n  rval = new uint16_t[length];\n  for (size_t i = 0; i < length; ++i) {\n    FromJSON_uint16_t(iterator, rval[i]);\n  }\n'
    },
    ('PPB_Core', 'IsMainThread', None): {
        'maybeNonMainThread': True
Ejemplo n.º 11
0
#!/usr/bin/env python
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import sys

from idl_log import ErrOut, InfoOut, WarnOut
from idl_option import GetOption, Option, ParseOptions
from idl_parser import ParseFiles

GeneratorList = []

Option('release', 'Which release to generate.', default='')
Option('range', 'Which ranges in the form of MIN,MAX.', default='start,end')


#
# Generator
#
# Base class for generators.  This class provides a mechanism for
# adding new generator objects to the IDL driver.  To use this class
# override the GenerateRelease and GenerateRange members, and
# instantiate one copy of the class in the same module which defines it to
# register the generator.  After the AST is generated, call the static Run
# member which will check every registered generator to see which ones have
# been enabled through command-line options.  To enable a generator use the
# switches:
#  --<sname> : To enable with defaults
#  --<sname>_opt=<XXX,YYY=y> : To enable with generator specific options.
#
Ejemplo n.º 12
0
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
""" Output file objects for generator. """

import difflib
import os
import time
import subprocess
import sys

from idl_log import ErrOut, InfoOut, WarnOut
from idl_option import GetOption, Option, ParseOptions
from stat import *

Option('diff', 'Generate a DIFF when saving the file.')


#
# IDLOutFile
#
# IDLOutFile provides a temporary output file.  By default, the object will
# not write the output if the file already exists, and matches what will be
# written.  This prevents the timestamp from changing to optimize cases where
# the output files are used by a timestamp dependent build system
#
class IDLOutFile(object):
    def __init__(self, filename, always_write=False, create_dir=True):
        self.filename = filename
        self.always_write = always_write
        self.create_dir = create_dir
Ejemplo n.º 13
0
import glob
import os
import re
import sys

from idl_log import ErrOut, InfoOut, WarnOut
from idl_node import IDLAttribute, IDLNode
from idl_ast import IDLAst
from idl_option import GetOption, Option, ParseOptions
from idl_outfile import IDLOutFile
from idl_parser import ParseFiles
from idl_cs_proto import CSGen, GetNodeComments, CommentLines, Comment
from idl_generator import Generator, GeneratorByFile
from idl_visitor import IDLVisitor

Option('cs_root', 'Base directory of output', default=os.path.join('..', 'peppersharp'))
Option('cs_guard', 'Include guard prefix', default=os.path.join('PepperSharp', 'c'))
Option('cs_namespace', 'Debug generate.', default='PepperSharp' )

#
# PrototypeResolver
#
# A specialized visitor which traverses the AST, building a mapping of
# Release names to Versions numbers and calculating a min version.
# The mapping is applied to the File nodes within the AST.
#
class ProtoResolver(IDLVisitor):
  def __init__(self):
    IDLVisitor.__init__(self)
    self.struct_map = {}
    self.interface_map = {}
Ejemplo n.º 14
0
#
# Try to load the ply module, if not, then assume it is in the third_party
# directory, relative to ppapi
#
try:
  from ply import lex
except:
  module_path, module_name = os.path.split(__file__)
  third_party = os.path.join(module_path, '..', '..', 'third_party')
  sys.path.append(third_party)
  from ply import lex

from idl_option import GetOption, Option, ParseOptions


Option('output', 'Generate output.')

#
# IDL Lexer
#
class IDLLexer(object):
  # 'tokens' is a value required by lex which specifies the complete list
  # of valid token types.
  tokens = [
    # Symbol and keywords types
      'COMMENT',
      'DESCRIBE',
      'ENUM',
      'LABEL',
      'SYMBOL',
      'INLINE',
Ejemplo n.º 15
0
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
""" Generator for C style prototypes and definitions """

import glob
import os
import sys

from idl_log import ErrOut, InfoOut, WarnOut
from idl_node import IDLNode
from idl_ast import IDLAst
from idl_option import GetOption, Option, ParseOptions
from idl_parser import ParseFiles

Option('cgen_debug', 'Debug generate.')


class CGenError(Exception):
    def __init__(self, msg):
        self.value = value

    def __str__(self):
        return repr(self.value)


def CommentLines(lines, tabs=0):
    # Generate a C style comment block by prepending the block with '<tab>/*'
    # and adding a '<tab> *' per line.
    tab = '  ' * tabs
Ejemplo n.º 16
0
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""
IDLRelease for PPAPI

This file defines the behavior of the AST namespace which allows for resolving
a symbol as one or more AST nodes given a Release or range of Releases.
"""

import sys

from idl_log import ErrOut, InfoOut, WarnOut
from idl_option import GetOption, Option, ParseOptions

Option('release_debug', 'Debug Release data')
Option('wgap', 'Ignore Release gap warning')

#
# Module level functions and data used for testing.
#
error = None
warning = None


def ReportReleaseError(msg):
    global error
    error = msg


def ReportReleaseWarning(msg):
Ejemplo n.º 17
0
import subprocess
import sys

from idl_option import GetOption, Option, ParseOptions
from idl_outfile import IDLOutFile
#
# IDLDiff
#
# IDLDiff is a tool for comparing sets of IDL generated header files
# with the standard checked in headers.  It does this by capturing the
# output of the standard diff tool, parsing it into separate changes, then
# ignoring changes that are know to be safe, such as adding or removing
# blank lines, etc...
#

Option('gen', 'IDL generated files', default='hdir')
Option('src', 'Original ".h" files', default='../c')
Option('halt', 'Stop if a difference is found')
Option('diff', 'Directory holding acceptable diffs', default='diff')
Option('ok', 'Write out the diff file.')
# Change
#
# A Change object contains the previous lines, new news and change type.
#
class Change(object):
  def __init__(self, mode, was, now):
    self.mode = mode
    self.was = was
    self.now = now

  def Dump(self):
Ejemplo n.º 18
0
import os.path
import re
import sys
import time

from idl_ast import IDLAst
from idl_log import ErrOut, InfoOut, WarnOut
from idl_lexer import IDLLexer
from idl_node import IDLAttribute, IDLFile, IDLNode
from idl_option import GetOption, Option, ParseOptions
from idl_lint import Lint

from ply import lex
from ply import yacc

Option('build_debug', 'Debug tree building.')
Option('parse_debug', 'Debug parse reduction steps.')
Option('token_debug', 'Debug token generation.')
Option('dump_tree', 'Dump the tree.')
Option('srcroot', 'Working directory.', default=os.path.join('..', 'api'))
Option('include_private',
       'Include private IDL directory in default API paths.')

#
# ERROR_REMAP
#
# Maps the standard error formula into a more friendly error message.
#
ERROR_REMAP = {
    'Unexpected ")" after "(".': 'Empty argument list.',
    'Unexpected ")" after ",".': 'Missing argument.',
Ejemplo n.º 19
0
#!/usr/bin/python
#
# Copyright (c) 2011 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import sys

from idl_log import ErrOut, InfoOut, WarnOut
from idl_option import GetOption, Option, ParseOptions

GeneratorList = []

Option('release', 'Which release to generate.', default='')
Option('range', 'Which ranges in the form of MIN,MAX.', default='M13,M16')

#
# Generator
#
# Base class for generators.  This class provides a mechanism for
# adding new generator objects to the IDL driver.  To use this class
# override the GenerateRelease and GenerateRange members, and
# instantiate one copy of the class in the same module which defines it to
# register the generator.  After the AST is generated, call the static Run
# member which will check every registered generator to see which ones have
# been enabled through command-line options.  To enable a generator use the
# switches:
#  --<sname> : To enable with defaults
#  --<sname>_opt=<XXX,YYY=y> : To enable with generator specific options.
#
# NOTE:  Generators still have access to global options