]> granicus.if.org Git - yasm/commitdiff
* value.pxi, expr.pxi: Copy instead of NULL'ing origin; this will look much
authorPeter Johnson <peter@tortall.net>
Mon, 3 Apr 2006 04:54:27 +0000 (04:54 -0000)
committerPeter Johnson <peter@tortall.net>
Mon, 3 Apr 2006 04:54:27 +0000 (04:54 -0000)
more pythonic on the python side, although it will cause much additional
object churn, and will not be fast.

svn path=/trunk/yasm/; revision=1453

tools/python-yasm/expr.pxi
tools/python-yasm/value.pxi

index 6bba8aefc599cb3d3ce4d67c0a0dc7d53db451e7..2befc0fb72b0714ea9be28d772b1f5cd6d6cb497 100644 (file)
@@ -146,21 +146,15 @@ cdef class Expression:
     cdef yasm_expr__item* __new_item(self, value) except NULL:
         cdef yasm_expr__item *retval
         if isinstance(value, Expression):
-            retval = yasm_expr_expr((<Expression>value).expr)
-            (<Expression>value).expr = NULL
-            return retval
+            return yasm_expr_expr(yasm_expr_copy((<Expression>value).expr))
         #elif isinstance(value, Symbol):
         #    return yasm_expr_sym((<Symbol>value).sym)
         #elif isinstance(value, Register):
         #    return yasm_expr_reg((<Register>value).reg)
         elif isinstance(value, FloatNum):
-            retval = yasm_expr_float((<FloatNum>value).flt)
-            (<FloatNum>value).flt = NULL
-            return retval
+            return yasm_expr_float(yasm_floatnum_copy((<FloatNum>value).flt))
         elif isinstance(value, IntNum):
-            retval = yasm_expr_int((<IntNum>value).intn)
-            (<IntNum>value).intn = NULL
-            return retval
+            return yasm_expr_int(yasm_intnum_copy((<IntNum>value).intn))
         else:
             try:
                 intnum = IntNum(value)
index 9cfffa5b02754684965a1296de72b125c3a844ce..c7bbe4a045db22cc97089309840f48ea49889858 100644 (file)
@@ -16,8 +16,8 @@ cdef class Value:
         if value is None:
             pass
         elif isinstance(value, Expression):
-            yasm_value_initialize(&self.value, (<Expression>value).expr)
-            (<Expression>value).expr = NULL
+            yasm_value_initialize(&self.value,
+                                  yasm_expr_copy((<Expression>value).expr))
         #elif isinstance(value, Symbol):
         else:
             raise ValueError("Invalid value type '%s'" % type(value))