1
0
Fork 0

Extensions: Add the CPackedStruct and the ByteArray>>castTo

This commit is contained in:
Holger Hans Peter Freyther 2010-10-16 15:19:57 +02:00
parent 340120f32f
commit ad18bed032
2 changed files with 28 additions and 22 deletions

View File

@ -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.
]
]

View File

@ -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)