19 |
19 |
20 ResourcePack comment:' |
20 ResourcePack comment:' |
21 COPYRIGHT (c) 1993 by Claus Gittinger |
21 COPYRIGHT (c) 1993 by Claus Gittinger |
22 All Rights Reserved |
22 All Rights Reserved |
23 |
23 |
24 $Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.14 1995-05-03 00:25:14 claus Exp $ |
24 $Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.15 1995-05-16 17:13:52 claus Exp $ |
25 '! |
25 '! |
26 |
26 |
27 !ResourcePack class methodsFor:'documentation'! |
27 !ResourcePack class methodsFor:'documentation'! |
28 |
28 |
29 copyright |
29 copyright |
299 " |
299 " |
300 ^ nil |
300 ^ nil |
301 ]. |
301 ]. |
302 self readFromResourceStream:inStream in:dirName. |
302 self readFromResourceStream:inStream in:dirName. |
303 inStream close. |
303 inStream close. |
|
304 ! |
|
305 |
|
306 processLine:aLine |
|
307 |lineString name stream l rest macroName value| |
|
308 |
|
309 lineString := lineString withoutSeparators. |
|
310 name := nil. |
|
311 (lineString at:1) == $' ifTrue:[ |
|
312 stream := ReadStream on:lineString. |
|
313 name := String |
|
314 readFrom:stream |
|
315 onError:['RESOURCEPACK: invalid line <',lineString,'>' errorPrintNl. nil]. |
|
316 l := stream position. |
|
317 |
|
318 "/ l := lineString indexOf:$' startingAt:2. |
|
319 "/ l ~~ 0 ifTrue:[ |
|
320 "/ name := (lineString copyFrom:2 to:l-1). |
|
321 "/ l := l + 1 |
|
322 "/ ] |
|
323 ] ifFalse:[ |
|
324 l := lineString indexOfSeparatorStartingAt:1. |
|
325 l ~~ 0 ifTrue:[ |
|
326 name := lineString copyFrom:1 to:l-1. |
|
327 ] |
|
328 ]. |
|
329 name notNil ifTrue:[ |
|
330 rest := (lineString copyFrom:l) withoutSeparators. |
|
331 " |
|
332 skip <type> if present |
|
333 " |
|
334 (rest startsWith:$<) ifTrue:[ |
|
335 l := lineString indexOf:$> startingAt:l. |
|
336 rest := (lineString copyFrom:l+1) withoutSeparators. |
|
337 ]. |
|
338 (rest startsWith:$=) ifTrue:[ |
|
339 rest := rest copyFrom:2. |
|
340 stream := ReadStream on:rest. |
|
341 macroName := stream nextAlphaNumericWord. |
|
342 rest := stream upToEnd. |
|
343 value := self at:macroName. |
|
344 value := Compiler evaluate:('self ' , rest) |
|
345 receiver:value |
|
346 notifying:nil |
|
347 compile:false. |
|
348 ] ifFalse:[ |
|
349 value := Compiler evaluate:rest compile:false. |
|
350 (value == #Error) ifTrue:[ |
|
351 Transcript show:('error in resource:' , name). |
|
352 ] |
|
353 ]. |
|
354 self at:name put:value. |
|
355 ] |
304 ! |
356 ! |
305 |
357 |
306 readFromResourceStream:inStream in:dirName |
358 readFromResourceStream:inStream in:dirName |
307 |lineString rest value ifLevel skipping l name first str macroName| |
359 |lineString rest value ifLevel skipping l name first str macroName| |
308 |
360 |