From: Peter Johnson Date: Mon, 3 Apr 2006 04:54:27 +0000 (-0000) Subject: * value.pxi, expr.pxi: Copy instead of NULL'ing origin; this will look much X-Git-Tag: v0.5.0rc2~2^2~16 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=549534bc03ffba026021e00413437dad59975746;p=yasm * value.pxi, expr.pxi: Copy instead of NULL'ing origin; this will look much 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 --- diff --git a/tools/python-yasm/expr.pxi b/tools/python-yasm/expr.pxi index 6bba8aef..2befc0fb 100644 --- a/tools/python-yasm/expr.pxi +++ b/tools/python-yasm/expr.pxi @@ -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((value).expr) - (value).expr = NULL - return retval + return yasm_expr_expr(yasm_expr_copy((value).expr)) #elif isinstance(value, Symbol): # return yasm_expr_sym((value).sym) #elif isinstance(value, Register): # return yasm_expr_reg((value).reg) elif isinstance(value, FloatNum): - retval = yasm_expr_float((value).flt) - (value).flt = NULL - return retval + return yasm_expr_float(yasm_floatnum_copy((value).flt)) elif isinstance(value, IntNum): - retval = yasm_expr_int((value).intn) - (value).intn = NULL - return retval + return yasm_expr_int(yasm_intnum_copy((value).intn)) else: try: intnum = IntNum(value) diff --git a/tools/python-yasm/value.pxi b/tools/python-yasm/value.pxi index 9cfffa5b..c7bbe4a0 100644 --- a/tools/python-yasm/value.pxi +++ b/tools/python-yasm/value.pxi @@ -16,8 +16,8 @@ cdef class Value: if value is None: pass elif isinstance(value, Expression): - yasm_value_initialize(&self.value, (value).expr) - (value).expr = NULL + yasm_value_initialize(&self.value, + yasm_expr_copy((value).expr)) #elif isinstance(value, Symbol): else: raise ValueError("Invalid value type '%s'" % type(value))