@@ -275,7 +275,9 @@ def emit_function(self, name, ctype, args, attrs, union=True):
275275
276276 def visitProduct (self , prod , name ):
277277 self .emit_function (name , get_c_type (name ),
278- self .get_args (prod .fields ), [], union = False )
278+ self .get_args (prod .fields ),
279+ self .get_args (prod .attributes ),
280+ union = False )
279281
280282
281283class FunctionVisitor (PrototypeVisitor ):
@@ -329,7 +331,8 @@ def emit(s, depth=0, reflow=True):
329331 self .emit (s , depth , reflow )
330332 for argtype , argname , opt in args :
331333 emit ("p->%s = %s;" % (argname , argname ), 1 )
332- assert not attrs
334+ for argtype , argname , opt in attrs :
335+ emit ("p->%s = %s;" % (argname , argname ), 1 )
333336
334337
335338class PickleVisitor (EmitVisitor ):
@@ -452,10 +455,15 @@ def visitProduct(self, prod, name):
452455 self .emit ("PyObject* tmp = NULL;" , 1 )
453456 for f in prod .fields :
454457 self .visitFieldDeclaration (f , name , prod = prod , depth = 1 )
458+ for a in prod .attributes :
459+ self .visitFieldDeclaration (a , name , prod = prod , depth = 1 )
455460 self .emit ("" , 0 )
456461 for f in prod .fields :
457462 self .visitField (f , name , prod = prod , depth = 1 )
463+ for a in prod .attributes :
464+ self .visitField (a , name , prod = prod , depth = 1 )
458465 args = [f .name for f in prod .fields ]
466+ args .extend ([a .name for a in prod .attributes ])
459467 self .emit ("*out = %s(%s);" % (name , self .buildArgs (args )), 1 )
460468 self .emit ("return 0;" , 1 )
461469 self .emit ("failed:" , 0 )
0 commit comments