ya-struct 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/layout.js +17 -1
- package/lib/layout.ts +17 -1
- package/package.json +1 -1
package/dist/lib/layout.js
CHANGED
|
@@ -95,6 +95,22 @@ const layoutStruct = ({
|
|
|
95
95
|
|
|
96
96
|
break;
|
|
97
97
|
}
|
|
98
|
+
case "array": {
|
|
99
|
+
|
|
100
|
+
// TODO: this is probably not sufficient for all cases
|
|
101
|
+
|
|
102
|
+
// eslint-disable-next-line no-use-before-define
|
|
103
|
+
const { sizeInBits } = layout({ definition: normalizedField.elementType, abi, currentOffsetInBits: 0 });
|
|
104
|
+
|
|
105
|
+
if (abi.compiler === "gcc" && abi.dataModel === "ILP32" && sizeInBits === 64) {
|
|
106
|
+
// special handling for gcc 64-bit integers on ILP32 data model (alignment to 32 bits)
|
|
107
|
+
currentOffsetInBits = align({ offset: currentOffsetInBits, alignment: 32 });
|
|
108
|
+
} else {
|
|
109
|
+
currentOffsetInBits = align({ offset: currentOffsetInBits, alignment: sizeInBits });
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
98
114
|
case "string": {
|
|
99
115
|
// no special alignment needed
|
|
100
116
|
break;
|
|
@@ -224,7 +240,7 @@ const layout = ({
|
|
|
224
240
|
definition: TFieldType,
|
|
225
241
|
abi: TAbi,
|
|
226
242
|
currentOffsetInBits: number
|
|
227
|
-
// eslint-disable-next-line complexity
|
|
243
|
+
// eslint-disable-next-line complexity
|
|
228
244
|
}*/)/*: TLayoutedField*/ => {
|
|
229
245
|
|
|
230
246
|
if (definition.type === "struct") {
|
package/lib/layout.ts
CHANGED
|
@@ -95,6 +95,22 @@ const layoutStruct = ({
|
|
|
95
95
|
|
|
96
96
|
break;
|
|
97
97
|
}
|
|
98
|
+
case "array": {
|
|
99
|
+
|
|
100
|
+
// TODO: this is probably not sufficient for all cases
|
|
101
|
+
|
|
102
|
+
// eslint-disable-next-line no-use-before-define
|
|
103
|
+
const { sizeInBits } = layout({ definition: normalizedField.elementType, abi, currentOffsetInBits: 0 });
|
|
104
|
+
|
|
105
|
+
if (abi.compiler === "gcc" && abi.dataModel === "ILP32" && sizeInBits === 64) {
|
|
106
|
+
// special handling for gcc 64-bit integers on ILP32 data model (alignment to 32 bits)
|
|
107
|
+
currentOffsetInBits = align({ offset: currentOffsetInBits, alignment: 32 });
|
|
108
|
+
} else {
|
|
109
|
+
currentOffsetInBits = align({ offset: currentOffsetInBits, alignment: sizeInBits });
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
98
114
|
case "string": {
|
|
99
115
|
// no special alignment needed
|
|
100
116
|
break;
|
|
@@ -224,7 +240,7 @@ const layout = ({
|
|
|
224
240
|
definition: TFieldType,
|
|
225
241
|
abi: TAbi,
|
|
226
242
|
currentOffsetInBits: number
|
|
227
|
-
// eslint-disable-next-line complexity
|
|
243
|
+
// eslint-disable-next-line complexity
|
|
228
244
|
}): TLayoutedField => {
|
|
229
245
|
|
|
230
246
|
if (definition.type === "struct") {
|
package/package.json
CHANGED