mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[0.2.x] ~fix append zero-size field
git-svn-id: https://pykd.svn.codeplex.com/svn@82225 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
14e20d47f2
commit
fd19126696
@ -81,7 +81,8 @@ void CustomStruct::appendField(const std::string &fieldName, TypeInfoPtr &fieldT
|
|||||||
ULONG offset = m_size;
|
ULONG offset = m_size;
|
||||||
ULONG align = fieldSize < m_align ? fieldSize : m_align;
|
ULONG align = fieldSize < m_align ? fieldSize : m_align;
|
||||||
|
|
||||||
offset += offset % align > 0 ? align - offset % align : 0;
|
if (align)
|
||||||
|
offset += offset % align > 0 ? align - offset % align : 0;
|
||||||
|
|
||||||
field->setOffset( offset );
|
field->setOffset( offset );
|
||||||
|
|
||||||
|
@ -58,6 +58,24 @@ class CustomTypesTest(unittest.TestCase):
|
|||||||
self.assertTrue( myType.fieldOffset("m_uint4") == 0 )
|
self.assertTrue( myType.fieldOffset("m_uint4") == 0 )
|
||||||
self.assertTrue( myType.fieldOffset("m_uint2") == 0 )
|
self.assertTrue( myType.fieldOffset("m_uint2") == 0 )
|
||||||
|
|
||||||
|
def testEmptyType(self):
|
||||||
|
tb = pykd.typeBuilder()
|
||||||
|
|
||||||
|
myEmptyStruct1 = tb.createStruct("EmptyStruct1")
|
||||||
|
self.assertEqual( 0, myEmptyStruct1.size() )
|
||||||
|
|
||||||
|
myEmptyStruct1.append("m_emptyStruct2", tb.createStruct("EmptyStruct2"))
|
||||||
|
self.assertEqual( 0, myEmptyStruct1.size() )
|
||||||
|
|
||||||
|
myEmptyUnion1 = tb.createUnion("EmptyUnion1")
|
||||||
|
self.assertEqual( 0, myEmptyUnion1.size() )
|
||||||
|
|
||||||
|
myEmptyStruct1.append("m_emptyUnion2", myEmptyUnion1)
|
||||||
|
self.assertEqual( 0, myEmptyStruct1.size() )
|
||||||
|
|
||||||
|
myEmptyUnion1.append("m_emptyStruct3", tb.createStruct("EmptyStruct3"))
|
||||||
|
self.assertEqual( 0, myEmptyUnion1.size() )
|
||||||
|
|
||||||
def testDupFieldName(self):
|
def testDupFieldName(self):
|
||||||
|
|
||||||
tb = pykd.typeBuilder()
|
tb = pykd.typeBuilder()
|
||||||
|
Loading…
Reference in New Issue
Block a user