From: Bert Vermeulen Date: Sat, 7 Jan 2012 03:18:16 +0000 (+0100) Subject: expose SRD_OUTPUT_* as symbols in the sigrokdecode module. X-Git-Tag: libsigrokdecode-0.1.0~198 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=3e2a9de2adfc73a640fa352fdc1ebc804fc98a69;p=libsigrokdecode.git expose SRD_OUTPUT_* as symbols in the sigrokdecode module. --- diff --git a/decoders/i2c.py b/decoders/i2c.py index 23b12c3..2a10ab7 100644 --- a/decoders/i2c.py +++ b/decoders/i2c.py @@ -180,8 +180,8 @@ class Decoder(sigrokdecode.Decoder): self.oldsda = None def start(self, metadata): - self.output_protocol = self.output_new(1, 'i2c') - self.output_annotation = self.output_new(0, 'i2c') + self.output_protocol = self.output_new(sigrokdecode.SRD_OUTPUT_PROTOCOL, 'i2c') + self.output_annotation = self.output_new(sigrokdecode.SRD_OUTPUT_ANNOTATION, 'i2c') def report(self): pass diff --git a/module_sigrokdecode.c b/module_sigrokdecode.c index b3bdafd..9c8c72e 100644 --- a/module_sigrokdecode.c +++ b/module_sigrokdecode.c @@ -220,6 +220,17 @@ PyMODINIT_FUNC PyInit_sigrokdecode(void) if (PyModule_AddObject(mod, "srd_logic", (PyObject *)&srd_logic_type) == -1) return NULL; + /* expose output types as symbols in the sigrokdecode module */ + if(PyModule_AddObject(mod, "SRD_OUTPUT_ANNOTATION", + PyLong_FromLong(SRD_OUTPUT_ANNOTATION)) == -1) + return NULL; + if(PyModule_AddObject(mod, "SRD_OUTPUT_PROTOCOL", + PyLong_FromLong(SRD_OUTPUT_PROTOCOL)) == -1) + return NULL; + if(PyModule_AddObject(mod, "SRD_OUTPUT_BINARY", + PyLong_FromLong(SRD_OUTPUT_BINARY)) == -1) + return NULL; + return mod; } diff --git a/sigrokdecode.h b/sigrokdecode.h index d58aea2..1080b44 100644 --- a/sigrokdecode.h +++ b/sigrokdecode.h @@ -66,6 +66,9 @@ enum { SRD_OUTPUT_ANNOTATION, SRD_OUTPUT_PROTOCOL, SRD_OUTPUT_BINARY, + /* When adding an output type, don't forget to expose it to PDs + * in controller.c:PyInit_sigrokdecode() + */ }; #define SRD_MAX_NUM_PROBES 64