Changeset 93acd9f


Ignore:
Timestamp:
Mar 9, 2013, 2:27:10 AM (12 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
5810ed4
Parents:
1e7a8f9
Message:

lib/generator.py: move add_generated_objects and generated_types_ready to .c file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/lib/generator.py

    r1e7a8f9 r93acd9f  
    143143"""
    144144
    145   for each in generated_objects:
    146       s += "extern PyTypeObject Py_%sType;\n" % \
    147               each.replace('aubio_','').replace('_t','')
    148 
    149145  types_ready = []
    150146  for each in generated_objects:
     
    152148              each.replace('aubio_','').replace('_t','') )
    153149
     150  s = """// generated list of objects created with generator.py
     151
     152#include "aubio-generated.h"
     153"""
     154
    154155  s += """
    155   int
    156   generated_types_ready (void)
    157   {
    158     return (
    159   """
     156int generated_types_ready (void)
     157{
     158  return (
     159"""
    160160  s += ('\n     ||').join(types_ready)
    161161  s += """);
    162   }
    163   """
     162}
     163"""
    164164
    165165  s += """
    166   void
    167   add_generated_objects ( PyObject *m )
    168   {"""
     166void add_generated_objects ( PyObject *m )
     167{"""
    169168  for each in generated_objects:
    170       s += """  Py_INCREF (&Py_%(name)sType);
    171     PyModule_AddObject (m, "%(name)s", (PyObject *) & Py_%(name)sType);""" % \
    172             { 'name': ( each.replace('aubio_','').replace('_t','') ) }
     169    s += """
     170  Py_INCREF (&Py_%(name)sType);
     171  PyModule_AddObject (m, "%(name)s", (PyObject *) & Py_%(name)sType);""" % \
     172          { 'name': ( each.replace('aubio_','').replace('_t','') ) }
    173173
    174174  s += """
    175   }"""
     175}"""
     176
     177  fd = open(os.path.join(output_path,'aubio-generated.c'), 'w')
     178  fd.write(s)
     179
     180  s = """// generated list of objects created with generator.py
     181
     182#include "Python.h"
     183
     184"""
     185
     186  for each in generated_objects:
     187      s += "extern PyTypeObject Py_%sType;\n" % \
     188              each.replace('aubio_','').replace('_t','')
     189
     190  s+= "int generated_objects ( void );\n"
     191  s+= "void add_generated_objects( PyObject *m );\n"
    176192
    177193  fd = open(os.path.join(output_path,'aubio-generated.h'), 'w')
Note: See TracChangeset for help on using the changeset viewer.