@@ -246,41 +246,43 @@ function ensure_line_feed_eol(ps::IO)
246
246
end
247
247
end
248
248
249
- #=
250
- Read the internal stream data and externalize to a temp file.
251
- If it's already an externalized stream then false is returned.
252
- The value can be stored in the stream object attribute so that the reverse
253
- process will be carried out for serialization.
254
- =#
255
- function read_internal_stream_data (ps:: IO , extent:: CosDict , len:: Int )
256
- get (extent, cn " F" ) != CosNull && return false
257
-
249
+ function read_internal_stream_data (extent:: CosDict , data)
258
250
(path, io) = get_tempfilepath ()
259
251
try
260
- data = read (ps, len)
261
252
write (io, data)
262
253
finally
263
254
util_close (io)
264
255
end
265
256
266
257
# Ensuring all the data is written to a file
267
258
set! (extent, cn " F" , CosLiteralString (path))
268
-
269
259
filter = get (extent, cn " Filter" )
270
260
if (filter != CosNull)
271
261
set! (extent, cn " FFilter" , filter)
272
262
set! (extent, cn " Filter" , CosNull)
273
263
end
274
-
275
264
parms = get (extent, cn " DecodeParms" )
276
265
if (parms != CosNull)
277
266
set! (extent, cn " FDecodeParms" , parms)
278
267
set! (extent, cn " DecodeParms" , CosNull)
279
268
end
280
-
281
269
return true
282
270
end
283
271
272
+ #=
273
+ Read the internal stream data and externalize to a temp file.
274
+ If it's already an externalized stream then false is returned.
275
+ The value can be stored in the stream object attribute so that the reverse
276
+ process will be carried out for serialization.
277
+ =#
278
+ function read_internal_stream_data (ps:: IO , extent:: CosDict , len:: Int )
279
+ get (extent, cn " F" ) != CosNull && return false
280
+ data = read (ps, len)
281
+ # Now eat away the ENDSTREAM token
282
+ chomp_space! (ps)
283
+ skipv (ps, ENDSTREAM)
284
+ return read_internal_stream_data (extent, data)
285
+ end
284
286
285
287
mutable struct CosObjectLoc
286
288
loc:: Int
@@ -292,49 +294,50 @@ end
292
294
process_stream_length (stmlen:: CosInt ,
293
295
ps:: IO ,
294
296
hoffset:: Int ,
295
- xref:: Dict{CosIndirectObjectRef, CosObjectLoc} )= stmlen
297
+ xref:: Dict{CosIndirectObjectRef, CosObjectLoc} ,
298
+ pred)= stmlen
296
299
297
300
function process_stream_length (stmlen:: CosIndirectObjectRef ,
298
301
ps:: IO ,
299
302
hoffset:: Int ,
300
- xref:: Dict{CosIndirectObjectRef, CosObjectLoc} )
303
+ xref:: Dict{CosIndirectObjectRef, CosObjectLoc} ,
304
+ pred)
301
305
cosObjectLoc = xref[stmlen]
302
- if (cosObjectLoc. obj === CosNull)
303
- seek (ps, cosObjectLoc. loc + hoffset)
304
- cosObjectLoc. obj = parse_indirect_obj (ps, hoffset, xref)
306
+ if cosObjectLoc. obj === CosNull
307
+ if cosObjectLoc. stm === CosNull
308
+ seek (ps, cosObjectLoc. loc + hoffset)
309
+ cosObjectLoc. obj = parse_indirect_obj (ps, hoffset, xref)
310
+ else
311
+ cosObjectLoc. obj = pred (cosObjectLoc. stm, stmlen, cosObjectLoc)
312
+ end
305
313
end
306
314
return cosObjectLoc. obj
307
315
end
308
316
309
317
function postprocess_indirect_object (ps:: IO , hoffset:: Int , obj:: CosDict ,
310
318
xref:: Dict {CosIndirectObjectRef,
311
- CosObjectLoc})
319
+ CosObjectLoc}, pred )
312
320
if locate_keyword! (ps, STREAM) == 0
313
321
ensure_line_feed_eol (ps)
314
322
pos = position (ps)
315
323
316
324
stmlen = get (obj, cn " Length" )
317
325
318
- lenobj = process_stream_length (stmlen, ps, hoffset, xref)
319
-
320
- len = get (lenobj)
326
+ lenobj = process_stream_length (stmlen, ps, hoffset, xref, pred)
321
327
322
328
if (lenobj != stmlen)
323
329
set! (obj, cn " Length" , lenobj)
324
330
end
325
331
332
+ len = get (lenobj)
333
+
326
334
seek (ps, pos)
327
335
328
336
# Here you can make sure file data is decoded into a file
329
- # later it can be made into a memory based on size etc.
337
+ # later it can be taken into memory based on size etc.
330
338
# Since, these are temporary files the spec is system file only
331
339
isInternal = read_internal_stream_data (ps, obj, len)
332
-
333
340
obj = CosStream (obj, isInternal)
334
-
335
- # Now eat away the ENDSTREAM token
336
- chomp_space! (ps)
337
- skipv (ps,ENDSTREAM)
338
341
obj = createIfObjectStream (obj)
339
342
end
340
343
return obj
@@ -343,11 +346,13 @@ end
343
346
postprocess_indirect_object (ps:: IO ,
344
347
hoffset:: Int ,
345
348
obj:: CosObject ,
346
- xref:: Dict{CosIndirectObjectRef, CosObjectLoc} ) = obj
349
+ xref:: Dict{CosIndirectObjectRef, CosObjectLoc} ,
350
+ pred) = obj
347
351
348
352
function parse_indirect_obj (ps:: IO ,
349
353
hoffset:: Int ,
350
- xref:: Dict{CosIndirectObjectRef, CosObjectLoc} )
354
+ xref:: Dict{CosIndirectObjectRef, CosObjectLoc} ,
355
+ pred= (x... )-> nothing )
351
356
chomp_space! (ps)
352
357
objn = parse_unsignednumber (ps). val
353
358
chomp_space! (ps)
@@ -356,7 +361,7 @@ function parse_indirect_obj(ps::IO,
356
361
skipv (ps, OBJ)
357
362
obj = parse_value (ps)
358
363
chomp_space! (ps)
359
- obj = postprocess_indirect_object (ps, hoffset, obj, xref)
364
+ obj = postprocess_indirect_object (ps, hoffset, obj, xref, pred )
360
365
chomp_space! (ps)
361
366
skipv (ps,ENDOBJ)
362
367
return CosIndirectObject (objn, genn, obj)
0 commit comments