| OLD | NEW |
| 1 # Python bindings for Yasm: Main Pyrex input file | 1 # Python bindings for Yasm: Main Pyrex input file |
| 2 # | 2 # |
| 3 # Copyright (C) 2006 Michael Urman, Peter Johnson | 3 # Copyright (C) 2006 Michael Urman, Peter Johnson |
| 4 # | 4 # |
| 5 # Redistribution and use in source and binary forms, with or without | 5 # Redistribution and use in source and binary forms, with or without |
| 6 # modification, are permitted provided that the following conditions | 6 # modification, are permitted provided that the following conditions |
| 7 # are met: | 7 # are met: |
| 8 # 1. Redistributions of source code must retain the above copyright | 8 # 1. Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # 2. Redistributions in binary form must reproduce the above copyright | 10 # 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 return NULL | 90 return NULL |
| 91 | 91 |
| 92 return PyCObject_AsVoidPtr(obj) | 92 return PyCObject_AsVoidPtr(obj) |
| 93 | 93 |
| 94 # | 94 # |
| 95 # Link to associated data mechanism to keep Python references paired with | 95 # Link to associated data mechanism to keep Python references paired with |
| 96 # yasm objects. | 96 # yasm objects. |
| 97 # | 97 # |
| 98 cdef class __assoc_data_callback: | 98 cdef class __assoc_data_callback: |
| 99 cdef yasm_assoc_data_callback *cb | 99 cdef yasm_assoc_data_callback *cb |
| 100 def __new__(self, destroy, print_): | 100 def __cinit__(self, destroy, print_): |
| 101 self.cb = <yasm_assoc_data_callback *>malloc(sizeof(yasm_assoc_data_call
back)) | 101 self.cb = <yasm_assoc_data_callback *>malloc(sizeof(yasm_assoc_data_call
back)) |
| 102 self.cb.destroy = <void (*) (void *)>PyCObject_AsVoidPtr(destroy) | 102 self.cb.destroy = <void (*) (void *)>PyCObject_AsVoidPtr(destroy) |
| 103 #self.cb.print_ = <void (*) (void *, FILE *, int)>PyCObject_AsVoidPtr(pr
int_) | 103 #self.cb.print_ = <void (*) (void *, FILE *, int)>PyCObject_AsVoidPtr(pr
int_) |
| 104 def __dealloc__(self): | 104 def __dealloc__(self): |
| 105 free(self.cb) | 105 free(self.cb) |
| 106 | 106 |
| 107 | 107 |
| 108 cdef class Register: | 108 cdef class Register: |
| 109 cdef unsigned long reg | 109 cdef unsigned long reg |
| 110 def __new__(self, reg): | 110 def __cinit__(self, reg): |
| 111 self.reg = reg | 111 self.reg = reg |
| 112 | 112 |
| 113 include "errwarn.pxi" | 113 include "errwarn.pxi" |
| 114 include "intnum.pxi" | 114 include "intnum.pxi" |
| 115 include "floatnum.pxi" | 115 include "floatnum.pxi" |
| 116 include "expr.pxi" | 116 include "expr.pxi" |
| 117 include "symrec.pxi" | 117 include "symrec.pxi" |
| 118 include "value.pxi" | 118 include "value.pxi" |
| 119 | 119 |
| 120 include "bytecode.pxi" | 120 include "bytecode.pxi" |
| 121 | 121 |
| 122 cdef __initialize(): | 122 cdef __initialize(): |
| 123 BitVector_Boot() | 123 BitVector_Boot() |
| 124 yasm_intnum_initialize() | 124 yasm_intnum_initialize() |
| 125 yasm_floatnum_initialize() | 125 yasm_floatnum_initialize() |
| 126 yasm_errwarn_initialize() | 126 yasm_errwarn_initialize() |
| 127 | 127 |
| 128 def __cleanup(): | 128 def __cleanup(): |
| 129 yasm_floatnum_cleanup() | 129 yasm_floatnum_cleanup() |
| 130 yasm_intnum_cleanup() | 130 yasm_intnum_cleanup() |
| 131 yasm_errwarn_cleanup() | 131 yasm_errwarn_cleanup() |
| 132 BitVector_Shutdown() | 132 BitVector_Shutdown() |
| 133 | 133 |
| 134 __initialize() | 134 __initialize() |
| 135 import atexit | 135 import atexit |
| 136 atexit.register(__cleanup) | 136 atexit.register(__cleanup) |
| 137 | 137 |
| OLD | NEW |