Skip to content

hhzl/Cuis-SQLite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SQLite3 for Cuis Smalltalk

"SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world. The source code for SQLite is in the public domain." https://sqlite.org/

This repostitory contains the access code to the library for Cuis Smalltalk https://github.com/jvuletich/Cuis. The code is nearly the same as the original for Squeak Smalltalk.

Original Squeak files used for the port

  • SQLite3-Core-ar.8.mcz
  • SQLite3-Tests-ar.4.mcz

from www.squeaksource.com

Author: Andreas Raab

Licence: MIT

Installation

You need a SQLite3 library from https://sqlite.org/download.html in your Cuis directory.

If you alrerady have installed FFI in Cuis

do

| slash |

slash _ FileDirectory slash.
{
     '..', slash, 'Cuis-SQLite3', slash, 'SQLite3-Core.pck.st' .
     '..', slash, 'Cuis-SQLite3', slash, 'SQLite3-Tests.pck.st' .
}

do:

[ :fileName | CodePackageFile installPackageStream:

             (FileStream concreteStream readOnlyFileNamed: fileName)
]   

otherwise download Cuis-FFI from https://github.com/hhzl/Cuis-FFI into a sibling directory and do

| slash |

slash _ FileDirectory slash.
{
	 '..', slash, 'Cuis-FFI', slash, 'FFI.pck.st' .
	 '..', slash, 'Cuis-SQLite3', slash, 'SQLite3-Core.pck.st' .
     '..', slash, 'Cuis-SQLite3', slash, 'SQLite3-Tests.pck.st' .
}

do:

[ :fileName | CodePackageFile installPackageStream:

             (FileStream concreteStream readOnlyFileNamed: fileName)
]   

Porting history

The files SQLite3-Core-ar.8.mcz and then SQLite3-Tests-ar.4.mcz could be filed in as is into Cuis.

A fix in the following method was necessary

Removed method #basicSqueakToIso

old

SqliteResult>>
readStringAtAddress: anAddress
	|deref i char|
	deref := anAddress pointerAt: 1.
	(deref allSatisfy: [:ea | ea = 0]) ifTrue: [^ nil].
	^ String streamContents:
		[:stream |
		i := 1.
		[(char := deref unsignedCharAt: i) asciiValue = 0] 
			whileFalse:
				[stream nextPut: char basicSqueakToIso.
				 i := i + 1]]

new

SqliteResult>>
readStringAtAddress: anAddress
	|deref i char|
	deref := anAddress pointerAt: 1.
	(deref allSatisfy: [:ea | ea = 0]) ifTrue: [^ nil].
	^ String streamContents:
		[:stream |
		i := 1.
		[(char := deref unsignedCharAt: i) asciiValue = 0] 
			whileFalse:
				[stream nextPut: char.
				 i := i + 1]]

All 5 tests out of 5 passed

Then the packages were saved and renamed as *.pck.st

About

Access library for SQLite3 databases for Cuis Smalltalk

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published