Extensions: Add the CPackedStruct and the ByteArray>>castTo
This commit is contained in:
parent
340120f32f
commit
ad18bed032
|
@ -42,5 +42,32 @@ Sockets.Socket extend [
|
|||
a := self next.
|
||||
^a isNil ifTrue: [a] ifFalse: [a asInteger]
|
||||
]
|
||||
|
||||
]
|
||||
|
||||
ByteArray extend [
|
||||
castTo: type [
|
||||
<category: 'private'>
|
||||
^ (CObject new storage: self) castTo: type
|
||||
]
|
||||
]
|
||||
|
||||
CCompound subclass: CPackedStruct [
|
||||
<shape: #word>
|
||||
<category: 'Language-C interface'>
|
||||
<comment: nil>
|
||||
|
||||
CPackedStruct class >> declaration: array [
|
||||
"Compile methods that implement the declaration in array."
|
||||
|
||||
<category: 'subclass creation'>
|
||||
self
|
||||
declaration: array
|
||||
inject: self superclass sizeof
|
||||
into: [:oldOffset :alignment | oldOffset]
|
||||
]
|
||||
|
||||
CPackedStruct class >> compileSize: size align: alignment [
|
||||
<category: 'private'>
|
||||
^ super compileSize: size align: 1.
|
||||
]
|
||||
]
|
||||
|
|
|
@ -25,27 +25,6 @@ Object subclass: IPAConstants [
|
|||
IPAConstants class >> idtagUnit [ ^ 16r08 ]
|
||||
]
|
||||
|
||||
CCompound subclass: CPackedStruct [
|
||||
<shape: #word>
|
||||
<category: 'Language-C interface'>
|
||||
<comment: nil>
|
||||
|
||||
CPackedStruct class >> declaration: array [
|
||||
"Compile methods that implement the declaration in array."
|
||||
|
||||
<category: 'subclass creation'>
|
||||
self
|
||||
declaration: array
|
||||
inject: self superclass sizeof
|
||||
into: [:oldOffset :alignment | oldOffset]
|
||||
]
|
||||
|
||||
CPackedStruct class >> compileSize: size align: alignment [
|
||||
<category: 'private'>
|
||||
^ super compileSize: size align: 1.
|
||||
]
|
||||
]
|
||||
|
||||
CPackedStruct subclass: IPASCCPState [
|
||||
<declaration: #(
|
||||
#(#src #uInt)
|
||||
|
|
Reference in New Issue