Windows API calls for Squeak 1.23

Alejandro F. Reimondo alereimondo at sugarweb.com
Mon Jan 12 09:12:40 UTC 1998


I've implemented API calls for Squeak 1.23 under Windows.
Framework supports source compatibility with Visual Smalltalk 3.1x and is expandable to support compatibility with Dolphin Smalltalk.

You can download the package (300kb) from
     http://www.sugarweb.com/Miniatures/Files/SqApis.Zip

or you can visit http://www.sugarWeb.com to see what is done in Smalltalk in Argentina
SUGAR is not an adition to Java, it is Smalltalk User Group of ARgentina.  :-)

Follows readme file
------------------------------------------------------------------
Windows API Calls for Squeak 1.23
---------------------------------
Version: 0.7

This package works correctly but is incomplete and not fully debugged.

Please report bugs and questions
	to Alejandro F. Reimondo
	at alereimondo at sugarWeb.com
Feel free to visit http://www.sugarweb.com
	(Smalltalk User Group ARgentina)
	for more recent versions and other works on Smalltalk in Argentina.

Intent:
-------

Implementation for Windows API calls compatible with Visual Smalltalk (3.1x) extensible to other API mechanisms like SOM (under OS2), OLE and Dolphin Smalltalk API.
An external library is seen as a subclass of DynamicLinkLibrary (for API calls) under category: 'Squeak External Calls'.
If you want to connect a new library you must evaluate:

Dynalink32 variableByteSubclass: #MyDLL
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Vsw310 - My DLLs'

and implement the class method #fileName like:

fileName
    "Answer the receiver's file name."
    ^'My.dll'

To load the library you can inspect the result of evaluating

MyDLL current inspect

"The message #current returns an open instance of aDynamicLinkLibrary and it is treated as the default library; then when another object evaluates 'MyDLL current' the same object will be returned.
If you want to open a new (fresh) instance you must send #open "

To free aDynamicLinkLibrary you MUST send #release

To implement an API call you must write a method.
Each function provided by the DLL must be implemented as a Smalltalk method.
API methods are methods like primitive methods but it has the <api: ...> descriptor (like <primitive:...>
API methods must provide:
	1.- the API function name
	2.- the argument types
	3.- the result type
See methods of KernelDLL UserDLL GDIDLL as examples.
API function name can be a symbol or a string matching to a function declared by the DLL.
Argument types are the argument types (that can be obtained from the .H file) and must match the types defined by the class apiInfo (see DynamicLinkLibrary>>#apiInfo).
Result type must be a valid API result defined by ApiInfo.

Example:

beep: frequency for: duration
    <api: Beep ulong ulong boolean>
    ^self invalidArgument

Defines an API function named 'Beep' that can be declared as
	BOOL Beep (int frecuency, int duration)
The #invalidArgument method is defined to validate posible API failure conditions.


How to start:
-------------

0.- Decompress the ZIP file in a directory (al decompressed source files must be in the same directory).
1.- Start your favourite (1.23) image with the virtual machine (sq.exe) provided in this package.
2.- FileIn the file 'API FileMeIn.txt' (answer NO to re-definitions)
3.- Evaluate testing the expressions with printIt (or DoIt).

Other topics of interest:
-------------------------

"To build a new virtual machine source file evaluate this expressions."
FileDirectory default deleteFileNamed: 'Interp.c'.
Interpreter translate: 'Interp.c' doInlining: true.

Limitations:
------------
1.- The framework if partially implemented and only supports API calls.
2.- You must initialize the framework at image startUp (prior to do an API call)
evaluating the expression
	DynamicLinkLibrary startUp.
3.- Currently the maximum of 20 arguments can be used in an API call.


File List:
----------
sq.exe			Virtual machine with API calls
API FileMeIn.txt	Installer file.
Readme.txt		This file.
API Test Script.st	Test scripts file.
Squeak External Calls.st	Full source file. (will be fragmented in the future)
Vsw310 Compatibility.st	Boot source file.
-------------------------------------------end of readme---


Ale.

Alejandro F. Reimondo
Feel free to visit Smalltalk User Group of Argentina (SUGAR)
at http://www.sugarWeb.com





More information about the Squeak-dev mailing list