Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
asdl_c.PrototypeVisitor Class Reference
Inheritance diagram for asdl_c.PrototypeVisitor:
Inheritance graph
[legend]
Collaboration diagram for asdl_c.PrototypeVisitor:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def visitModule
def visitType
def visitSum
def get_args
def visitConstructor
def emit_function
def visitProduct
def emit
def visit

Public Attributes

 file
 cache
 skip
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Detailed Description

Generate function prototypes for the .h file

Definition at line 208 of file asdl_c.py.


Member Function Documentation

def asdl_c.EmitVisitor.emit (   self,
  s,
  depth,
  reflow = True 
) [inherited]

Definition at line 89 of file asdl_c.py.

00089 
00090     def emit(self, s, depth, reflow=True):
00091         # XXX reflow long lines?
00092         if reflow:
00093             lines = reflow_lines(s, depth)
00094         else:
00095             lines = [s]
00096         for line in lines:
00097             line = (" " * TABSIZE * depth) + line + "\n"
00098             self.file.write(line)
00099 

Here is the call graph for this function:

def asdl_c.PrototypeVisitor.emit_function (   self,
  name,
  ctype,
  args,
  attrs,
  union = True 
)

Reimplemented in asdl_c.FunctionVisitor.

Definition at line 258 of file asdl_c.py.

00258 
00259     def emit_function(self, name, ctype, args, attrs, union=True):
00260         args = args + attrs
00261         if args:
00262             argstr = ", ".join(["%s %s" % (atype, aname)
00263                                 for atype, aname, opt in args])
00264             argstr += ", PyArena *arena"
00265         else:
00266             argstr = "PyArena *arena"
00267         margs = "a0"
00268         for i in range(1, len(args)+1):
00269             margs += ", a%d" % i
00270         self.emit("#define %s(%s) _Py_%s(%s)" % (name, margs, name, margs), 0,
00271                 reflow=False)
00272         self.emit("%s _Py_%s(%s);" % (ctype, name, argstr), False)

Here is the call graph for this function:

Here is the caller graph for this function:

def asdl_c.PrototypeVisitor.get_args (   self,
  fields 
)
Return list of C argument into, one for each field.

Argument info is 3-tuple of a C type, variable name, and flag
that is true if type can be NULL.

Definition at line 225 of file asdl_c.py.

00225 
00226     def get_args(self, fields):
00227         """Return list of C argument into, one for each field.
00228 
00229         Argument info is 3-tuple of a C type, variable name, and flag
00230         that is true if type can be NULL.
00231         """
00232         args = []
00233         unnamed = {}
00234         for f in fields:
00235             if f.name is None:
00236                 name = f.type
00237                 c = unnamed[name] = unnamed.get(name, 0) + 1
00238                 if c > 1:
00239                     name = "name%d" % (c - 1)
00240             else:
00241                 name = f.name
00242             # XXX should extend get_c_type() to handle this
00243             if f.seq:
00244                 if f.type.value in ('cmpop',):
00245                     ctype = "asdl_int_seq *"
00246                 else:
00247                     ctype = "asdl_seq *"
00248             else:
00249                 ctype = get_c_type(f.type)
00250             args.append((ctype, name, f.opt or f.seq))
00251         return args

Here is the call graph for this function:

Here is the caller graph for this function:

def asdl.VisitorBase.visit (   self,
  object,
  args 
) [inherited]

Definition at line 319 of file asdl.py.

00319 
00320     def visit(self, object, *args):
00321         meth = self._dispatch(object)
00322         if meth is None:
00323             return
00324         try:
00325             meth(object, *args)
00326         except Exception:
00327             output("Error visiting" + repr(object))
00328             output(str(sys.exc_info()[1]))
00329             traceback.print_exc()
00330             # XXX hack
00331             if hasattr(self, 'file'):
00332                 self.file.flush()
00333             os._exit(1)

Here is the call graph for this function:

Here is the caller graph for this function:

def asdl_c.PrototypeVisitor.visitConstructor (   self,
  cons,
  type,
  attrs 
)

Definition at line 252 of file asdl_c.py.

00252 
00253     def visitConstructor(self, cons, type, attrs):
00254         args = self.get_args(cons.fields)
00255         attrs = self.get_args(attrs)
00256         ctype = get_c_type(type)
00257         self.emit_function(cons.name, ctype, args, attrs)

Here is the call graph for this function:

Here is the caller graph for this function:

def asdl_c.PrototypeVisitor.visitModule (   self,
  mod 
)

Definition at line 211 of file asdl_c.py.

00211 
00212     def visitModule(self, mod):
00213         for dfn in mod.dfns:
00214             self.visit(dfn)

Here is the call graph for this function:

def asdl_c.PrototypeVisitor.visitProduct (   self,
  prod,
  name 
)

Definition at line 273 of file asdl_c.py.

00273 
00274     def visitProduct(self, prod, name):
00275         self.emit_function(name, get_c_type(name),
00276                            self.get_args(prod.fields), [], union=False)
00277 

Here is the call graph for this function:

def asdl_c.PrototypeVisitor.visitSum (   self,
  sum,
  name 
)

Definition at line 218 of file asdl_c.py.

00218 
00219     def visitSum(self, sum, name):
00220         if is_simple(sum):
00221             pass # XXX
00222         else:
00223             for t in sum.types:
00224                 self.visit(t, name, sum.attributes)

Here is the call graph for this function:

def asdl_c.PrototypeVisitor.visitType (   self,
  type 
)

Definition at line 215 of file asdl_c.py.

00215 
00216     def visitType(self, type):
00217         self.visit(type.value, type.name)

Here is the call graph for this function:


Member Data Documentation

Definition at line 316 of file asdl.py.

Definition at line 86 of file asdl_c.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.

asdl.VisitorBase.skip [inherited]

Definition at line 317 of file asdl.py.


The documentation for this class was generated from the following file: