From: Robert Bradshaw Date: Tue, 29 Apr 2008 05:29:10 +0000 (-0700) Subject: public enum X-Git-Tag: 0.9.6.14~9 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=2984ce161c60c3f78bbdf1f9d15d634c6986577d;p=cython.git public enum --- diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index 522b50c0..40bf51eb 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -757,10 +757,23 @@ class CEnumDefNode(StatNode): item.analyse_declarations(env, self.entry) def analyse_expressions(self, env): - pass + if self.visibility == 'public': + self.temp = env.allocate_temp_pyobject() + env.release_temp(self.temp) def generate_execution_code(self, code): - pass + if self.visibility == 'public': + for item in self.entry.enum_values: + code.putln("%s = PyInt_FromLong(%s); %s" % ( + self.temp, + item.cname, + code.error_goto_if_null(self.temp, item.pos))) + code.putln('if (PyObject_SetAttrString(%s, "%s", %s) < 0) %s' % ( + Naming.module_cname, + item.name, + self.temp, + code.error_goto(item.pos))) + code.putln("%s = 0;" % self.temp) class CEnumDefItemNode(StatNode): diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index b4133efb..dcb928da 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -1090,6 +1090,8 @@ def p_for_bounds(s): 'relation2': rel2, 'bound2': bound2, 'step': step } + else: + s.error("Expected 'in' or 'from'") def p_for_from_relation(s): if s.sy in inequality_relations: