Skip to content

Commit 5693002

Browse files
author
James Foster
committed
Update for GemStone 3.5.
1 parent f164cea commit 5693002

File tree

3 files changed

+38
-10
lines changed

3 files changed

+38
-10
lines changed

GciLibrary.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
class GciLibrary:
1010

11-
def __init__(self, version='3.4.3', directory=os.getcwd()):
12-
self._initLibrary(version, directory)
11+
def __init__(self, version='3.5.0'):
12+
os.environ["GEMSTONE"] = os.getcwd()
13+
self._initLibrary(version, os.getcwd() + '/lib/')
1314

1415
self.gciI32ToOop = self.library.GciI32ToOop
1516
self.gciI32ToOop.restype = c_int32

GciTests.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,49 @@
11
"""
22
>>> # See gcits.hf for details
33
4+
>>> # obtain an object representing the C library
45
>>> gci = GciLibrary()
56
>>> isinstance(gci, GciLibrary)
67
True
78
9+
>>> # simplest test to see if we have a GCI library
810
>>> gci.version()
9-
'3.4.3 build gss64_3_4_x_branch-45183'
11+
'3.5.0 build 64bit-46205'
1012
11-
>>> gci.oopToChar(16668)
13+
>>> # convert a Smalltalk OOP to an ASCII character
14+
>>> gci.oopToChar(16668) # $A
1215
65
1316
17+
>>> # this OOP is not a valid character
1418
>>> gci.oopToChar(16667)
1519
-1
1620
1721
>>> gci.oopToChar(24860) # $a
1822
97
1923
20-
>>> gci.charToOop(65)
24+
>>> # convert an ASCII code point to a Smalltalk OOP
25+
>>> gci.charToOop(65) # $A
2126
16668
2227
2328
>>> gci.charToOop(97) # $a
2429
24860
2530
31+
>>> # we can convert Unicode as well
2632
>>> gci.charToOop(1114111)
2733
285212444
2834
35+
>>> # this is not a valid character, so get back OOP_INVALID (1)
2936
>>> gci.charToOop(1114112)
3037
1
3138
39+
>>> # convert a double to a Smalltalk OOP
3240
>>> try:
3341
... gci.doubleToSmallDouble(1.0)
3442
... except InvalidArgumentError:
3543
... "InvalidArgumentError"
3644
9151314442816847878
3745
46+
>>> # demonstrate that we can properly handle exceptions
3847
>>> try:
3948
... gci.doubleToSmallDouble(1e40)
4049
... except InvalidArgumentError:
@@ -47,6 +56,7 @@
4756
>>> gci.I32ToOop(55)
4857
442
4958
59+
>>> # expect an exception for a bad login argument
5060
>>> try:
5161
... gci.login(gem_host=gem_host, netldi='badldi', stone='badstone')
5262
... except GciException as ex:
@@ -65,13 +75,15 @@
6575
... ex.number() # invalid user/password
6676
4051
6777
78+
>>> # using the provided login info we should be successful
6879
>>> session = gci.login(gem_host=gem_host, netldi=netldi, stone=stone, gs_user=gs_user, gs_password=gs_password)
6980
>>> isinstance(session, int) # successful login
7081
True
7182
7283
>>> gci.is_session_valid(session)
7384
True
7485
86+
>>> # do a name lookup of an object (with a well-known OOP)
7587
>>> symbolName = 'Globals'
7688
>>> try:
7789
... gci.resolveSymbol(session, symbolName)
@@ -86,6 +98,7 @@
8698
... ex.number()
8799
2101
88100
101+
>>> # the following should quietly succeed
89102
>>> try:
90103
... gci.abort(session)
91104
... except GciException as ex:
@@ -101,14 +114,17 @@
101114
... except GciException as ex:
102115
... ex.number()
103116
117+
>>> # logout should not error
104118
>>> try:
105119
... gci.logout(session)
106120
... except GciException as ex:
107121
... ex.number() # invalid session
108122
123+
>>> # session should no longer be valid
109124
>>> gci.is_session_valid(session)
110125
False
111126
127+
>>> # subsequent logout attempts should fail
112128
>>> try:
113129
... gci.logout(session)
114130
... except GciException as ex:
@@ -137,12 +153,17 @@
137153

138154
if __name__ == '__main__':
139155
import os
156+
# Create a local login file that is not under version control
140157
if (not os.path.isfile('GciLogin.py')):
141158
import shutil
142159
shutil.copy2('GciDefault.py', 'GciLogin.py')
160+
# Import interesting things from GciLibrary
143161
from GciLibrary import GciLibrary, GciException, InvalidArgumentError
162+
# Get local login information (not under version control)
144163
from GciLogin import *
164+
# Import testing framework
145165
import doctest
146166
print('Start tests')
167+
# Run tests shown in docstring above
147168
doctest.testmod()
148169
print('End tests')

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,17 @@
44

55
GemBuilder for C documentation ([HTML](https://downloads.gemtalksystems.com/docs/GemStone64/3.4.x/GS64-GemBuilderC-3.4/GS64-GemBuilderC-3.4.htm) or [PDF](https://downloads.gemtalksystems.com/docs/GemStone64/3.4.x/GS64-GemBuilderforC-3.4.pdf)) describes the API for the *single-threaded* GCI library. We are using a new *thread-safe* library that has fewer functions (but more features). It is not separately documented, but has a header file, `gcits.hf`, that is the definitive specification (a recent copy is included with this checkout).
66

7-
The needed C libraries are not included as part of this checkout since there is a different set of libraries for each platform (Linux, macOS, and Windows), and for each GemStone version. You should download a recent version and the appropriate [product](https://gemtalksystems.com/products/gs64/) for your platform. Then move the appropriate files into this directory.
8-
9-
* Linux: libfloss-3.4.x-64.so and libgcits-3.4.x-64.so
10-
* macOS: libfloss-3.4.x-64.dylib and libgcits-3.4.x-64.dylib
11-
* Windows: libgcits-3.4.x-32.dll and libssl-3.4.x-32.dll
7+
The needed C libraries are not included as part of this checkout since there is a different set of libraries for each platform (Linux, macOS, and Windows), and for each GemStone version. You should download a recent version and the appropriate [product](https://gemtalksystems.com/products/gs64/) for your platform. Then move the appropriate files into the `./lib/` directory (below this README.md file).
8+
9+
* Linux:
10+
* libfloss-3.4.x-64.so and libgcits-3.4.x-64.so
11+
* libgcits-3.5.x-64.so, libkrb5-3.5.x-64.so and libssl-3.5.0-64.so
12+
* macOS:
13+
* libfloss-3.4.x-64.dylib and libgcits-3.4.x-64.dylib
14+
* libgcits-3.5.x-64.dylib, libkrb5-3.5.x-64.dylib, and libssl-3.5.0-64.dylib
15+
* Windows:
16+
* libgcits-3.4.x-32.dll and libssl-3.4.x-32.dll
17+
* libgcits-3.5.x-32.dll and libssl-3.5.x-32.dll
1218

1319
## Files
1420

0 commit comments

Comments
 (0)