1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
|
<?
ficlPageHeader("upgrading ficl")
ficlAddToNavBarAs("Upgrading To 4.0")
def startoldvsnew(extra = None):
print "<table width=100%><tr>\n"
print "<td bgcolor=#d0d0f0><b>old name</b></td>\n"
print "<td bgcolor=#e0e0ff><b>new name</td>\n"
if extra != None:
print "<td bgcolor=#d0d0f0><b>" + extra + "</td>\n"
print "</tr>\n"
def oldvsnew(old, new, extra = None):
print "<tr>\n"
print "<td bgcolor=#e0e0e0><code>" + old + "</code></td>\n"
print "<td bgcolor=#f0f0f0><code>" + new + "</code></td>\n"
if extra != None:
print "<td bgcolor=#e0e0e0><code>" + extra + "</code></td>\n"
print"</tr>\n\n"
def endoldvsnew():
print "</table><p>\n"
?>
Ficl 4.0 is smaller, faster, and more capable than any previous
version. For more information on why Ficl 4.0 is so gosh-darned
swell, see the <a href=index.html#WhatsNewInFicl4.0>What's New In Ficl 4.0?</a>
section of the overview.
<p>
Since the Ficl API has changed so dramatically, you can't just drop
the new Ficl source. You have two basic choices:
<a href=#compatibility>use the <code>FICL_WANT_COMPATIBILITY</code> support</a>, and
<a href=#newapi>switching to the new API</a>.
<p>
Note that using <i>either</i> of these choices <i>requires</i>
that you recompile your application. You cannot build Ficl 4 into
a shared library or DLL and use it with an application expecting
Ficl 3.0. Stated another way: Ficl 4 is <i>source</i> compatible
but not <i>binary</i> compatible with Ficl 3.
<a name=oldnames>
<? ficlHeader1("Using <code>FICL_WANT_COMPATIBILITY</code>") ?>
</a>
If you want to get Ficl 4.0 up and running in your project as quickly
as possible, <code>FICL_WANT_COMPATIBILITY</code> is what you'll want to use.
There are two easy steps, one of which you might be able to skip:
<p>
<ol>
<li>
Set the C preprocessor constant <code>FICL_WANT_COMPATIBILITY</code> to 1.
The best way is by adding the following line to <code>ficllocal.h</code>:
<pre>
#define FICL_WANT_COMPATIBILITY (1)
</pre>
<li>
<i>If</i> you use a custom <code>ficlTextOut()</code> function, you'll
have to rename it, and explicitly specify it to Ficl. Renaming it is
necessary, because the Ficl compatibility layer also provides one for
code that called <code>ficlTextOut()</code> directly (instead of calling
<code>vmTextOut()</code> as it should have).
We recommend renaming your function to <code>ficlTextOutLocal()</code>, as
we have have provided a prototype for this function for you in <code>ficlcompatibility.h</code>.
This will save you the trouble of defining your own prototype, ensuring you get
correct name decoration / linkage, etc.
<p>
There are two methods you can use to specify your <code>ficlTextOut()</code>
function:
<ol>
<li>
Specify it in the <code>FICL_INIT_INFO</code> structure passed in to
<code>ficlInitSystem()</code>. This is the preferred method, as it ensures
you will see the results of Ficl's initialization code, and it will be
automatically passed in to every newly created VM.
<li>
Set it explicitly in every VM by calling <code>vmSetTextOut()</code> and
passing it in.
</ol>
<p>
<b>Note:</b> Any other method, such as setting it by hand in the
<code>FICL_SYSTEM</code> or <code>FICL_VM</code> structures,
will <b>not</b> work. There is a special compatibility layer for old-style
<code>OUTFUNC</code> functions, but it is only invoked properly when you
use one of the two methods mentioned above.
</ol>
<p>
This <i>should</i> be sufficient for you to recompile-and-go
with Ficl 4. If it's not, please let us know, preferably including a
suggested solution to the problem.
<a name=newapi>
<? ficlHeader1("Using The New API") ?>
</a>
Since most (all?) of the external symbols have changed names since the 3.0 series,
here is a quick guide to get you started on renaming everything. This is by no
means an exhaustive list; this is meant to guide you towards figuring out what
the new name <i>should</i> be. (After all, part of the point of this massive
renaming was to make all the external symbols consistent.)
<p>
<? ficlHeader2("Types") ?>
Every external type has been renamed. They all begin with the
word <code>ficl</code>, and they use mixed case (instead of all upper-case,
which is now reserved for macros). Also, the confusingly-named
string objects have been renamed:
<code>FICL_STRING</code> is now <code>ficlCountedString</code>, as it
represents a "counted string" in the language, and
the more commonly-used <code>STRINGINFO</code> is now simply
<code>ficlString</code>.
<?
startoldvsnew()
oldvsnew("FICL_SYSTEM", "ficlSystem")
oldvsnew("FICL_VM", "ficlVm")
oldvsnew("FICL_SYSTEM_INFO", "ficlSystemInformation")
oldvsnew("FICL_WORD", "ficlWord")
oldvsnew("IPTYPE", "ficlIp")
oldvsnew("FICL_CODE", "ficlPrimitive")
oldvsnew("OUTFUNC", "ficlOutputFunction")
oldvsnew("FICL_DICTIONARY", "ficlDictionary")
oldvsnew("FICL_STACK", "ficlStack")
oldvsnew("STRINGINFO", "ficlString")
oldvsnew("FICL_STRING", "ficlCountedString")
endoldvsnew()
?>
<? ficlHeader2("Structure Members") ?>
In addition, many structure names have changed. To help ease the heartache,
we've also added some accessor macros. So, in case they change in the future,
your code might still compile (hooray!).
<?
startoldvsnew("accessor")
oldvsnew("pExtend", "context", "ficlVmGetContext(), ficlSystemGetContext()")
oldvsnew("pStack", "dataStack", "ficlVmGetDataStack()")
oldvsnew("fStack", "floatStack", "ficlVmGetFloatStack()")
oldvsnew("rStack", "returnStack", "ficlVmGetReturnStack()")
endoldvsnew()
?>
<? ficlHeader2("Callback Functions") ?>
Text output callbacks have changed in two major ways:
<ul>
<li>
They no longer take a VM pointer; they now take a <code>ficlCallback</code> structure.
This allows output to be printed before a VM is defined, or in circumstances where a
VM may not be defined (such as an assertion failure in a <code>ficlSystem...()</code> function).
<li>
They no longer take a flag indicating whether or not to add a "newline".
Instead, the function must output a newline whenever it encounters
a <code>\n</code> character in the text.
</ul>
If you don't want to rewrite your output function yet, you can
"thunk" the new-style call to the old-style. Just pass in <code>ficlOldnamesCallbackTextOut</code>
as the name of the output function for the system and VM, and then set
the <code>thunkedTextout</code> member of the <code>ficlSystem</code>
or <code>ficlVm</code> to your old-style text output function.
<? ficlHeader2("Renamed Macros") ?>
<?
startoldvsnew()
oldvsnew("PUSHPTR(p)", "ficlStackPushPointer(vm->dataStack, p)")
oldvsnew("POPUNS()", "ficlStackPopUnsigned(vm->dataStack)")
oldvsnew("GETTOP()", "ficlStackGetTop(vm->dataStack)")
oldvsnew("FW_IMMEDIATE", "FICL_WORD_IMMEDIATE")
oldvsnew("FW_COMPILE", "FICL_WORD_COMPILE_ONLY")
oldvsnew("VM_INNEREXIT", "FICL_VM_STATUS_INNER_EXIT")
oldvsnew("VM_OUTOFTEXT", "FICL_VM_STATUS_OUT_OF_TEXT")
oldvsnew("VM_RESTART", "FICL_VM_RESTART")
endoldvsnew()
?>
<? ficlHeader2("<code>ficllocal.h</code>") ?>
One more note about macros. Ficl now ships with a standard place for
you to tweak the Ficl compile-time preprocessor switches such as
<code>FICL_WANT_COMPATIBILITY</code> and <code>FICL_WANT_FLOAT</code>.
It's a file called <code>ficllocal.h</code>, and we guarantee that it
will always ship empty (or with only comments). We suggest that you
put all your local changes there, rather than editing <code>ficl.h</code>
or editing the makefile. That should make it much easier to integrate
future Ficl releases into your product—all you need do is preserve
your tweaked copy of <code>ficllocal.h</code> and replace the rest.
<? ficlHeader2("Renamed Functions") ?>
Every function that deals primarily with a particular structure
is now named after that structure. For instance, any function
that takes a <code>ficlSystem</code> as its first argument is
named <code>ficlSystem<i>Something</i>()</code>. Any function
that takes a <code>ficlVm</code> as its first argument is
named <code>ficlVm<i>Something</i>()</code>. And so on.
<p>
Also, functions that create a new object are always
called <code>Create</code> (not <code>Alloc</code>, <code>Allot</code>, <code>Init</code>, or <code>New</code>).
Functions that create a new object are always
called <code>Destroy</code> (not <code>Free</code>, <code>Term</code>, or <code>Delete</code>).
<p>
<?
startoldvsnew()
oldvsnew("ficlInitSystem()", "ficlSystemCreate()")
oldvsnew("ficlTermSystem()", "ficlSystemDestroy()")
oldvsnew("ficlNewVM()", "ficlSystemCreateVm()")
oldvsnew("ficlFreeVM()", "ficlVmDestroy()")
oldvsnew("dictCreate()", "ficlDictionaryCreate()")
oldvsnew("dictDelete()", "ficlDictionaryDestroy()")
endoldvsnew()
?>
<p>
All functions exported by Ficl now start with the word <code>ficl</code>.
This is a <i>feature</i>, as it means the Ficl project will no longer
pollute your namespace.
<?
startoldvsnew()
oldvsnew("PUSHPTR(p)", "ficlStackPushPointer(vm->dataStack, p)")
oldvsnew("POPUNS()", "ficlStackPopUnsigned(vm->dataStack)")
oldvsnew("GETTOP()", "ficlStackGetTop(vm->dataStack)")
oldvsnew("ltoa()", "ficlLtoa()")
oldvsnew("strincmp()", "ficlStrincomp()")
endoldvsnew()
?>
<? ficlHeader2("Removed Functions") ?>
A few entry points have simply been removed.
For instance, functions specifically managing a system's <code>ENVIRONMENT</code>
settings have been removed, in favor of managing the system's
<code>environment</code> dictionary directly:
<?
startoldvsnew()
oldvsnew("ficlSystemSetEnvironment(system)", "ficlDictionarySetConstant(ficlSystemGetEnvironment(system), ...)")
oldvsnew("ficlSystemSet2Environment(system)", "ficlDictionarySet2Constant(ficlSystemGetEnvironment(system), ...)")
endoldvsnew()
?>
In a similar vein, <code>ficlSystemBuild()</code> has been removed in favor
of using <code>ficlDictionarySetPrimitive()</code> directly:
<?
startoldvsnew()
oldvsnew("ficlSystemBuild(system, ...)", "ficlDictionarySetPrimitive(ficlSystemGetDictionary(system), ...)")
endoldvsnew()
?>
Finally, there is no <i>exact</i> replacement for <code>ficlExec()</code>. 99% of the code
that called <code>ficlExec()</code> never bothered to manage <code>SOURCE-ID</code> properly.
If you were calling <code>ficlExec()</code>, and you weren't changing <code>SOURCE-ID</code>
(or <code>vm->sourceId</code>) to match, you should replace those calls with <code>ficlVmEvaluate()</code>,
which will manage <code>SOURCE-ID</code> for you.
<p>
There <i>is</i> a function that takes the place of <code>ficlExec()</code> which doesn't change
<code>SOURCE-ID</code>: <code>ficlVmExecuteString()</code>. However, instead of taking a
straight C string (a <code>char *</code>), it takes a <code>ficlString *</code> as its
code argument. (This is to discourage its use.)
<?
ficlHeader1("Internal Changes")
?>
<b>Note:</b> none of these changes should affect you. If they do, there's probably
a problem somewhere. Either Ficl's API doesn't abstract away something enough, or
you are approaching a problem the wrong way. Food for thought.
<p>
There's only one internal change worth noting here.
The top value on a Ficl stack used to be at (to use the modern structure names)
<code>stack->top[-1]</code>. It is now at <code>stack->top[0]</code>.
In other words, the "stack top" pointer used to point <i>past</i> the top
element; it now points <i>at</i> the top element. (Pointing <i>at</i> the
top element is not only less confusing, it is also faster.)
</body>
</html>
|