1926
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1998 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
"{ Package: 'stx:libbasic2' }"
|
|
13 |
|
605
|
14 |
ExternalBytes subclass:#ExternalLong
|
|
15 |
instanceVariableNames:''
|
|
16 |
classVariableNames:''
|
|
17 |
poolDictionaries:''
|
623
|
18 |
category:'System-Support'
|
605
|
19 |
!
|
|
20 |
|
1926
|
21 |
!ExternalLong class methodsFor:'documentation'!
|
|
22 |
|
|
23 |
copyright
|
|
24 |
"
|
|
25 |
COPYRIGHT (c) 1998 by eXept Software AG
|
|
26 |
All Rights Reserved
|
|
27 |
|
|
28 |
This software is furnished under a license and may be used
|
|
29 |
only in accordance with the terms of that license and with the
|
|
30 |
inclusion of the above copyright notice. This software may not
|
|
31 |
be provided or otherwise made available to, or used by, any
|
|
32 |
other person. No title to or ownership of the software is
|
|
33 |
hereby transferred.
|
|
34 |
"
|
2329
|
35 |
!
|
|
36 |
|
|
37 |
documentation
|
|
38 |
"
|
|
39 |
mostly added for odbc
|
|
40 |
"
|
1926
|
41 |
! !
|
605
|
42 |
|
|
43 |
!ExternalLong class methodsFor:'instance creation'!
|
|
44 |
|
|
45 |
new
|
2517
|
46 |
"allocate some memory usable for data;
|
|
47 |
the memory is not controlled by the garbage collector.
|
|
48 |
Return a corresponding ExternalBytes object or raise MallocFailure (if malloc fails).
|
|
49 |
|
|
50 |
Use this, if you have to pass a block of bytes to some
|
|
51 |
external destination (such as a C function) which does not copy the
|
|
52 |
data, but instead keeps a reference to it. For example, many functions
|
|
53 |
which expect strings simply keep a ref to the passed string - for those,
|
|
54 |
an ST/X string-pointer is not the right thing to pass, since ST/X objects
|
|
55 |
may change their address.
|
|
56 |
|
|
57 |
DANGER ALERT: the memory is NOT automatically freed until it is either
|
|
58 |
MANUALLY freed (see #free) or the returned externalBytes object
|
|
59 |
is unprotected or the classes releaseAllMemory method is called."
|
|
60 |
|
605
|
61 |
^ super new:4
|
|
62 |
|
|
63 |
"
|
|
64 |
ExternalLong new
|
|
65 |
"
|
2517
|
66 |
|
|
67 |
"Modified: / 20-12-2010 / 16:22:51 / cg"
|
605
|
68 |
!
|
|
69 |
|
|
70 |
unprotectedNew
|
2517
|
71 |
"allocate some memory usable for data;
|
|
72 |
the memory is under the control of the garbage collector.
|
|
73 |
Return a corresponding ExternalBytes object or raise MallocFailure (if malloc fails).
|
|
74 |
|
|
75 |
DANGER ALERT: the memory block as allocated will be automatically freed
|
|
76 |
as soon as the reference to the returned externalBytes object
|
|
77 |
is gone (by the next garbage collect).
|
|
78 |
If the memory has been passed to a C-function which
|
|
79 |
remembers this pointer, bad things may happen ...."
|
|
80 |
|
605
|
81 |
^ super unprotectedNew:4
|
|
82 |
|
|
83 |
"
|
|
84 |
ExternalLong new
|
|
85 |
"
|
2517
|
86 |
|
|
87 |
"Modified: / 20-12-2010 / 16:22:39 / cg"
|
605
|
88 |
! !
|
|
89 |
|
|
90 |
!ExternalLong methodsFor:'accessing'!
|
|
91 |
|
|
92 |
asBoolean
|
|
93 |
|result|
|
|
94 |
|
609
|
95 |
result := self byteAt:1.
|
605
|
96 |
result = 0 ifTrue:[
|
|
97 |
^ false.
|
|
98 |
].
|
|
99 |
^ true.
|
|
100 |
!
|
|
101 |
|
|
102 |
asInteger
|
609
|
103 |
^ self signedWordAt:1 MSB:false
|
605
|
104 |
|
|
105 |
"
|
|
106 |
ODBCLibrary::ExternalLong new value:10
|
|
107 |
"
|
|
108 |
!
|
|
109 |
|
|
110 |
asNullStatus
|
|
111 |
|result|
|
|
112 |
|
|
113 |
result := self wordAt:1 MSB:false.
|
2329
|
114 |
result = 0 ifTrue:[ ^ #SQL_NO_NULLS ].
|
|
115 |
result = 1 ifTrue:[ ^ #SQL_NULLABLE ].
|
|
116 |
^ #SQL_NULLABLE_UNKNOWN
|
|
117 |
!
|
|
118 |
|
|
119 |
asPointer
|
2330
|
120 |
^ ExternalAddress new setAddress:(self value)
|
2329
|
121 |
|
|
122 |
"
|
|
123 |
(ExternalLong new value:10) asPointer
|
|
124 |
"
|
605
|
125 |
!
|
|
126 |
|
609
|
127 |
boolean:bool
|
|
128 |
bool ifTrue:[self byteAt:1 put:1].
|
|
129 |
self byteAt:1 put:0.
|
|
130 |
!
|
|
131 |
|
605
|
132 |
value
|
|
133 |
^ self doubleWordAt:1
|
|
134 |
|
|
135 |
"
|
623
|
136 |
ExternalLong new value:10
|
605
|
137 |
"
|
623
|
138 |
|
|
139 |
"Modified: / 30.3.1998 / 17:07:57 / cg"
|
605
|
140 |
!
|
|
141 |
|
|
142 |
value:anInteger
|
|
143 |
self doubleWordAt:1 put:anInteger
|
|
144 |
! !
|
|
145 |
|
2462
|
146 |
!ExternalLong methodsFor:'printing & storing'!
|
|
147 |
|
|
148 |
printOn:aStream
|
|
149 |
aStream nextPutAll:self className; nextPut:$(.
|
|
150 |
self asInteger printOn:aStream.
|
|
151 |
aStream nextPut:$)
|
|
152 |
! !
|
|
153 |
|
605
|
154 |
!ExternalLong class methodsFor:'documentation'!
|
|
155 |
|
|
156 |
version
|
2517
|
157 |
^ '$Header: /cvs/stx/stx/libbasic2/ExternalLong.st,v 1.8 2010-12-20 15:29:36 cg Exp $'
|
2329
|
158 |
!
|
|
159 |
|
|
160 |
version_CVS
|
2517
|
161 |
^ '$Header: /cvs/stx/stx/libbasic2/ExternalLong.st,v 1.8 2010-12-20 15:29:36 cg Exp $'
|
605
|
162 |
! !
|