@@ -49,8 +49,14 @@ def __set__(self, instance, value):
49
49
if not self .fset :
50
50
raise AttributeError ("%s is read-only" % self .__name__ )
51
51
return self .fset .__get__ (instance , None )(value )
52
- def add_attribute (self , attribute ):
53
- self ._clr_attributes_ .append (attribute )
52
+ def add_attribute (self , * args , ** kwargs ):
53
+ lst = []
54
+ if len (args ) > 0 :
55
+ if isinstance (args [0 ], tuple ):
56
+ lst = args
57
+ else :
58
+ lst = [(args [0 ], args [1 :], kwargs )]
59
+ self ._clr_attributes_ .extend (lst )
54
60
return self
55
61
56
62
class property (object ):
@@ -68,9 +74,16 @@ def __get__(self, instance, owner):
68
74
return v
69
75
def __set__ (self , instance , value ):
70
76
self .values [instance ] = value
71
- def add_attribute (self , attribute ):
72
- self ._clr_attributes_ .append (attribute )
77
+ def add_attribute (self , * args , ** kwargs ):
78
+ lst = []
79
+ if len (args ) > 0 :
80
+ if isinstance (args [0 ], tuple ):
81
+ lst = args
82
+ else :
83
+ lst = [(args [0 ], args [1 :], kwargs )]
84
+ self ._clr_attributes_ .extend (lst )
73
85
return self
86
+
74
87
def __call__ (self , type , default ):
75
88
self2 = self .__class__ (self ._clr_property_type_ , type , default )
76
89
self2 ._clr_attributes_ = self ._clr_attributes_
@@ -118,22 +131,34 @@ def __call__(self, func):
118
131
def __get__ (self , instance , owner ):
119
132
return self .__func .__get__ (instance , owner )
120
133
121
- def clr_attribute (self , attribute ):
122
- self ._clr_attributes_ .append (attribute )
134
+ def add_attribute (self , * args , ** kwargs ):
135
+ lst = []
136
+ if len (args ) > 0 :
137
+ if isinstance (args [0 ], tuple ):
138
+ lst = args
139
+ else :
140
+ lst = [(args [0 ], args [1 :], kwargs )]
141
+ self ._clr_attributes_ .extend (lst )
123
142
return self
124
143
125
144
class attribute (object ):
126
145
127
- def __init__ (self , attr , * args , ** kwargs ):
128
- self .attr = attr
146
+ def __init__ (self , * args , ** kwargs ):
147
+ lst = []
148
+ if len (args ) > 0 :
149
+ if isinstance (args [0 ], tuple ):
150
+ lst = args
151
+ else :
152
+ lst = [(args [0 ], args [1 :], kwargs )]
129
153
import Python .Runtime
130
154
#todo: ensure that attributes only are pushed when @ is used.
131
- #import inspect
132
- #Python.Runtime.PythonDerivedType.Test(inspect.stack()[1].code_context)
155
+ self .attr = lst
156
+ for item in lst :
157
+ Python .Runtime .PythonDerivedType .PushAttribute (item )
133
158
134
- Python .Runtime .PythonDerivedType .PushAttribute (attr )
135
159
def __call__ (self , x ):
136
160
import Python .Runtime
137
- if Python .Runtime .PythonDerivedType .AssocAttribute (self .attr , x ):
138
- pass
161
+ for item in self .attr :
162
+ if Python .Runtime .PythonDerivedType .AssocAttribute (item , x ):
163
+ pass
139
164
return x
0 commit comments