xml2py different output (order of definitions) when running with same input file twice.
Swix Blue <[email protected]> Wed, 9 Feb 2011 08:44:21 +0100
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <[email protected]> |
Hi! I've been using ctypeslib in a project to share a common api between C code and python code using C header files. It works great except that I recently discovered that the xml2py function generates different python code for the same input run twice. It looks like it has to do with the enums in the header file. (The h2xml always generates the same xml file). I've attached the header file simple.h, and two example outputs from running: -------------------- from ctypeslib import h2xml, xml2py import os h2xml.compile_to_xml(['h2xml','-q',os.getcwd()+'/simple.h','-o','simple.xml']) xml2py.main(['xml2py','simple.xml','-o','simple1.py']) xml2py.main(['xml2py','simple.xml','-o','simple2.py']) ------------------------ I'm using version 0.5.6 of ctypeslib. Is there a setting I could use to have xml2py always generate the same python file for same header file? Thanks ------------------------------------------------------------------------------ The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE: Pinpoint memory and threading errors before they happen. Find and fix more than 250 security defects in the development cycle. Locate bottlenecks in serial and parallel code that limit performance. http://p.sf.net/sfu/intel-dev2devfeb _______________________________________________ ctypes-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ctypes-users
simple.h
(text/x-chdr, 681 B)
#ifndef SIMPLE_H
#define SIMPLE_H
typedef enum SubSystem
{
SUBSYSTEM_1 = 0,
SUBSYSTEM_2,
SUBSYSTEM_3,
SUBSYSTEM_4,
SUBSYSTEM_END, /* Leave this end field second last */
SUBSYSTEM_UNDEF = 0xfe, /* Leave this define last */
SUBSYSTEM_RESERVED = 0xff /* Do not use, it's for future extensions */
}SUBSYSTEM_TYPE;
typedef enum InterfaceType
{
INTERFACE_1 = 0,
INTERFACE_2,
INTERFACE_3,
INTERFACE_END, /* Leave this end field second last */
INTERFACE_UNDEF = 0xfe, /* Leave this define last */
INTERFACE_TYPE_RESERVED = 0xff /* Do not use, it's for future extensions */
}INTERFACE_TYPE;
#endif
simple1.py
(text/x-python, 821 B)
from ctypes import *
SUBSYSTEM_3 = 2
INTERFACE_3 = 2
INTERFACE_TYPE_RESERVED = 255
INTERFACE_UNDEF = 254
SUBSYSTEM_2 = 1
SUBSYSTEM_RESERVED = 255
INTERFACE_2 = 1
INTERFACE_END = 3
SUBSYSTEM_END = 4
INTERFACE_1 = 0
SUBSYSTEM_UNDEF = 254
SUBSYSTEM_4 = 3
SUBSYSTEM_1 = 0
# values for enumeration 'SubSystem'
SubSystem = c_int # enum
SUBSYSTEM_TYPE = SubSystem
# values for enumeration 'InterfaceType'
InterfaceType = c_int # enum
INTERFACE_TYPE = InterfaceType
__all__ = ['SubSystem', 'SUBSYSTEM_TYPE', 'SUBSYSTEM_UNDEF',
'SUBSYSTEM_1', 'INTERFACE_TYPE', 'INTERFACE_END',
'INTERFACE_2', 'InterfaceType', 'SUBSYSTEM_4',
'SUBSYSTEM_3', 'SUBSYSTEM_2', 'SUBSYSTEM_END',
'INTERFACE_TYPE_RESERVED', 'SUBSYSTEM_RESERVED',
'INTERFACE_3', 'INTERFACE_UNDEF', 'INTERFACE_1']
simple2.py
(text/x-python, 821 B)
from ctypes import *
INTERFACE_2 = 1
SUBSYSTEM_RESERVED = 255
SUBSYSTEM_END = 4
SUBSYSTEM_1 = 0
INTERFACE_3 = 2
SUBSYSTEM_3 = 2
SUBSYSTEM_UNDEF = 254
INTERFACE_UNDEF = 254
SUBSYSTEM_4 = 3
INTERFACE_END = 3
INTERFACE_TYPE_RESERVED = 255
INTERFACE_1 = 0
SUBSYSTEM_2 = 1
# values for enumeration 'SubSystem'
SubSystem = c_int # enum
SUBSYSTEM_TYPE = SubSystem
# values for enumeration 'InterfaceType'
InterfaceType = c_int # enum
INTERFACE_TYPE = InterfaceType
__all__ = ['SubSystem', 'SUBSYSTEM_TYPE', 'SUBSYSTEM_END',
'INTERFACE_TYPE', 'INTERFACE_END', 'INTERFACE_UNDEF',
'InterfaceType', 'SUBSYSTEM_4', 'SUBSYSTEM_3',
'SUBSYSTEM_2', 'SUBSYSTEM_1', 'INTERFACE_TYPE_RESERVED',
'SUBSYSTEM_RESERVED', 'INTERFACE_3', 'INTERFACE_2',
'INTERFACE_1', 'SUBSYSTEM_UNDEF']