f149dc12
Andreas Rumpf
first somewhat wo...
|
1
2
3
|
The file to generate given testlib.nim would be `Testlib.st`. This is the class
old "chunk format" in which the content is separated by `!` marks, in a rather
oddish way, but anyway.
|
70473583
Göran Krampe
First sample and ...
|
4
5
6
7
8
9
|
Let's go through it:
```
'From Nim on 18 February 2015 at 11:15:50 pm'!
```
|
f149dc12
Andreas Rumpf
first somewhat wo...
|
10
11
|
Above first chunk is just a String literal with a timestamp, that chunk can
be omitted.
|
70473583
Göran Krampe
First sample and ...
|
12
13
14
15
16
17
18
19
|
```
ExternalLibrary subclass: #Testlib
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Nim'!
```
|
f149dc12
Andreas Rumpf
first somewhat wo...
|
20
21
22
|
Then follows the class declaration. Obviously we need to make sure it says
`Testlib` and the category will equal the package in Squeak that this class
will end up in. For now, let's hard code it to `Nim`.
|
70473583
Göran Krampe
First sample and ...
|
23
|
|
f149dc12
Andreas Rumpf
first somewhat wo...
|
24
25
|
Then we can see that there is a "whitespace only" chunk, since the next part
starts with `!`.
|
70473583
Göran Krampe
First sample and ...
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
```
!Testlib class methodsFor: 'primitives' stamp: 'gk 11/2/2014 13:05'!
```
This chunk says here follows methods for "Testlib class" (=class side) in method category "primitives" (we can hardcode it to that).
```
ffiAdd: a with: b
"self ffiAdd: 13 with: 29"
<cdecl: long 'add' (long long) module: 'testlib'>
^self externalCallFailed!
ffiConcat: a with: b
"self ffiConcat: 'a' with: 'b' "
<cdecl: char* 'concat' (char* char*) module: 'testlib'>
^self externalCallFailed!
ffiFoo
"self ffiFoo"
<cdecl: char* 'foo' () module: 'testlib'>
^self externalCallFailed!
ffiHello
"self ffiHello"
"long is int in Nim"
<cdecl: long 'hello' () module: 'testlib'>
^self externalCallFailed!
ffiLength: x
"self ffiLen: 'hey' "
<cdecl: long 'length' (char*) module: 'testlib'>
^self externalCallFailed! !
```
The above is one chunk per method, then an extra empty chunk on the last line to finish the method category "primitives".
```
!Testlib class methodsFor: 'accessing' stamp: 'gk 2/18/2015 23:13'!
moduleName
^'testlib'! !
```
Finally a chunk declaring another method category, and then a single method with the name of the shared library to load.
|