1 // Copyright (c) 1996 James Clark
2 // See the file copying.txt for copying permission.
7 #include "Interpreter.h"
8 #include "InterpreterMessages.h"
11 #ifdef DSSSL_NAMESPACE
12 namespace DSSSL_NAMESPACE {
15 InheritedC::InheritedC(const Identifier *ident, unsigned index)
16 : ident_(ident), index_(index)
20 InheritedC::~InheritedC()
24 void InheritedC::invalidValue(const Location &loc,
25 Interpreter &interp) const
27 interp.invalidCharacteristicValue(identifier(), loc);
30 class BoolInheritedC : public InheritedC {
32 BoolInheritedC(const Identifier *, unsigned index, bool);
33 ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const;
38 BoolInheritedC::BoolInheritedC(const Identifier *ident, unsigned index, bool value)
39 : InheritedC(ident, index), value_(value)
43 ELObj *BoolInheritedC::value(VM &vm, const VarStyleObj *, Vector<size_t> &) const
46 return vm.interp->makeTrue();
48 return vm.interp->makeFalse();
51 class IntegerInheritedC : public InheritedC {
53 IntegerInheritedC(const Identifier *, unsigned index, long);
54 ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const;
59 IntegerInheritedC::IntegerInheritedC(const Identifier *ident, unsigned index, long n)
60 : InheritedC(ident, index), n_(n)
64 ELObj *IntegerInheritedC::value(VM &vm, const VarStyleObj *, Vector<size_t> &) const
66 return vm.interp->makeInteger(n_);
69 class LengthInheritedC : public InheritedC {
71 LengthInheritedC(const Identifier *, unsigned index, FOTBuilder::Length);
72 ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const;
74 FOTBuilder::Length size_;
77 LengthInheritedC::LengthInheritedC(const Identifier *ident, unsigned index, FOTBuilder::Length size)
78 : InheritedC(ident, index), size_(size)
82 ELObj *LengthInheritedC::value(VM &vm, const VarStyleObj *, Vector<size_t> &) const
84 return new (*vm.interp) LengthObj(size_);
87 class SymbolInheritedC : public InheritedC {
89 SymbolInheritedC(const Identifier *, unsigned index, FOTBuilder::Symbol);
90 ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const;
92 FOTBuilder::Symbol sym_;
95 SymbolInheritedC::SymbolInheritedC(const Identifier *ident, unsigned index, FOTBuilder::Symbol sym)
96 : InheritedC(ident, index), sym_(sym)
100 ELObj *SymbolInheritedC::value(VM &vm, const VarStyleObj *, Vector<size_t> &) const
102 return vm.interp->cValueSymbol(sym_);
105 class PublicIdInheritedC : public InheritedC {
107 PublicIdInheritedC(const Identifier *, unsigned index,
108 FOTBuilder::PublicId = 0);
109 ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const;
111 FOTBuilder::PublicId pubid_;
114 PublicIdInheritedC::PublicIdInheritedC(const Identifier *ident, unsigned index, FOTBuilder::PublicId pubid)
115 : InheritedC(ident, index), pubid_(pubid)
119 ELObj *PublicIdInheritedC::value(VM &vm, const VarStyleObj *, Vector<size_t> &) const
121 Interpreter &interp = *vm.interp;
123 return new (interp) StringObj(interp.makeStringC(pubid_));
125 return interp.makeFalse();
128 class Letter2InheritedC : public InheritedC {
130 Letter2InheritedC(const Identifier *, unsigned index,
131 FOTBuilder::Letter2 = 0);
132 ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const;
134 FOTBuilder::Letter2 code_;
137 Letter2InheritedC::Letter2InheritedC(const Identifier *ident, unsigned index,
138 FOTBuilder::Letter2 code)
139 : InheritedC(ident, index), code_(code)
143 ELObj *Letter2InheritedC::value(VM &vm, const VarStyleObj *, Vector<size_t> &) const
145 Interpreter &interp = *vm.interp;
148 buf += (code_ >> 8) & 0xff;
151 return interp.makeSymbol(buf);
154 return interp.makeFalse();
157 class LengthSpecInheritedC : public InheritedC {
159 LengthSpecInheritedC(const Identifier *, unsigned index, FOTBuilder::Length);
160 ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const;
162 bool setValue(ELObj *, const Location &, Interpreter &);
163 FOTBuilder::LengthSpec value_;
167 LengthSpecInheritedC::LengthSpecInheritedC(const Identifier *ident,
168 unsigned index, FOTBuilder::Length n)
169 : InheritedC(ident, index), value_(n)
173 ELObj *LengthSpecInheritedC::value(VM &vm, const VarStyleObj *,
174 Vector<size_t> &) const
176 return vm.interp->makeLengthSpec(value_);
179 bool LengthSpecInheritedC::setValue(ELObj *obj, const Location &loc,
182 return interp.convertLengthSpecC(obj, identifier(), loc, value_);
185 class OptLengthSpecInheritedC : public InheritedC {
187 OptLengthSpecInheritedC(const Identifier *, unsigned index);
188 ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const;
190 bool setValue(ELObj *, const Location &, Interpreter &);
191 FOTBuilder::OptLengthSpec value_;
195 OptLengthSpecInheritedC::OptLengthSpecInheritedC(const Identifier *ident,
197 : InheritedC(ident, index)
201 ELObj *OptLengthSpecInheritedC::value(VM &vm, const VarStyleObj *,
202 Vector<size_t> &) const
204 if (!value_.hasLength)
205 return vm.interp->makeFalse();
207 return vm.interp->makeLengthSpec(value_.length);
210 bool OptLengthSpecInheritedC::setValue(ELObj *obj, const Location &loc,
213 return interp.convertOptLengthSpecC(obj, identifier(), loc, value_);
216 class StringInheritedC : public InheritedC {
218 StringInheritedC(const Identifier *, unsigned index, const Char *, size_t );
219 StringInheritedC(const Identifier *, unsigned index, const StringC &);
220 ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const;
225 StringInheritedC::StringInheritedC(const Identifier *ident, unsigned index,
226 const Char *s, size_t n)
227 : InheritedC(ident, index), str_(s, n)
231 StringInheritedC::StringInheritedC(const Identifier *ident, unsigned index,
233 : InheritedC(ident, index), str_(s)
237 ELObj *StringInheritedC::value(VM &vm, const VarStyleObj *, Vector<size_t> &) const
239 return new(*vm.interp) StringObj(str_);
242 class GenericInlineSpaceInheritedC : public InheritedC {
244 typedef void (FOTBuilder::*Setter)(const FOTBuilder::InlineSpace &);
245 GenericInlineSpaceInheritedC(const Identifier *, unsigned index, Setter setter);
246 ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const;
247 void set(VM &, const VarStyleObj *, FOTBuilder &,
248 ELObj *&value, Vector<size_t> &dependencies) const;
249 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
251 FOTBuilder::InlineSpace value_;
255 GenericInlineSpaceInheritedC::GenericInlineSpaceInheritedC(const Identifier *ident,
258 : InheritedC(ident, index), setter_(setter)
262 ELObj *GenericInlineSpaceInheritedC::value(VM &vm, const VarStyleObj *,
263 Vector<size_t> &) const
265 return new (*vm.interp) InlineSpaceObj(value_);
268 void GenericInlineSpaceInheritedC::set(VM &, const VarStyleObj *,
271 Vector<size_t> &) const
273 (fotb.*setter_)(value_);
277 GenericInlineSpaceInheritedC::make(ELObj *obj, const Location &loc,
278 Interpreter &interp) const
280 GenericInlineSpaceInheritedC *copy
281 = new GenericInlineSpaceInheritedC(identifier(), index(), setter_);
282 InlineSpaceObj *iso = obj->asInlineSpace();
284 copy->value_ = iso->inlineSpace();
287 else if (interp.convertLengthSpecC(obj, identifier(), loc, copy->value_.nominal)) {
288 copy->value_.min = copy->value_.nominal;
289 copy->value_.max = copy->value_.nominal;
297 class GenericBoolInheritedC : public BoolInheritedC {
299 typedef void (FOTBuilder::*Setter)(bool);
300 GenericBoolInheritedC(const Identifier *, unsigned index, Setter,
302 void set(VM &, const VarStyleObj *, FOTBuilder &,
303 ELObj *&value, Vector<size_t> &dependencies) const;
304 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
309 GenericBoolInheritedC
310 ::GenericBoolInheritedC(const Identifier *ident, unsigned index,
311 Setter setter, bool b)
312 : BoolInheritedC(ident, index, b), setter_(setter)
316 void GenericBoolInheritedC::set(VM &, const VarStyleObj *,
319 Vector<size_t> &) const
321 (fotb.*setter_)(value_);
325 GenericBoolInheritedC::make(ELObj *obj, const Location &loc,
326 Interpreter &interp) const
329 if (interp.convertBooleanC(obj, identifier(), loc, b))
330 return new GenericBoolInheritedC(identifier(), index(), setter_, b);
331 return ConstPtr<InheritedC>();
334 class ExtensionBoolInheritedC : public BoolInheritedC {
336 typedef void (FOTBuilder::*Setter)(bool);
337 ExtensionBoolInheritedC(const Identifier *, unsigned index, Setter,
339 void set(VM &, const VarStyleObj *, FOTBuilder &,
340 ELObj *&value, Vector<size_t> &dependencies) const;
341 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
346 ExtensionBoolInheritedC
347 ::ExtensionBoolInheritedC(const Identifier *ident, unsigned index,
348 Setter setter, bool b)
349 : BoolInheritedC(ident, index, b), setter_(setter)
353 void ExtensionBoolInheritedC::set(VM &, const VarStyleObj *,
356 Vector<size_t> &) const
358 fotb.extensionSet(setter_, value_);
362 ExtensionBoolInheritedC::make(ELObj *obj, const Location &loc,
363 Interpreter &interp) const
366 if (interp.convertBooleanC(obj, identifier(), loc, b))
367 return new ExtensionBoolInheritedC(identifier(), index(), setter_, b);
368 return ConstPtr<InheritedC>();
371 class ExtensionStringInheritedC : public StringInheritedC {
373 typedef void (FOTBuilder::*Setter)(const StringC &);
374 ExtensionStringInheritedC(const Identifier *, unsigned index, Setter);
375 ExtensionStringInheritedC(const Identifier *, unsigned index, Setter,
376 const Char *, size_t);
377 void set(VM &, const VarStyleObj *, FOTBuilder &,
378 ELObj *&value, Vector<size_t> &dependencies) const;
379 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
384 ExtensionStringInheritedC
385 ::ExtensionStringInheritedC(const Identifier *ident, unsigned index,
387 : StringInheritedC(ident, index, StringC()), setter_(setter)
391 ExtensionStringInheritedC
392 ::ExtensionStringInheritedC(const Identifier *ident, unsigned index,
393 Setter setter, const Char *s, size_t n)
394 : StringInheritedC(ident, index, s, n), setter_(setter)
398 void ExtensionStringInheritedC::set(VM &, const VarStyleObj *,
401 Vector<size_t> &) const
403 fotb.extensionSet(setter_, str_);
407 ExtensionStringInheritedC::make(ELObj *obj, const Location &loc,
408 Interpreter &interp) const
412 if (obj->stringData(s, n))
413 return new ExtensionStringInheritedC(identifier(), index(), setter_, s, n);
414 invalidValue(loc, interp);
415 return ConstPtr<InheritedC>();
418 class ExtensionIntegerInheritedC : public IntegerInheritedC {
420 typedef void (FOTBuilder::*Setter)(long);
421 ExtensionIntegerInheritedC(const Identifier *, unsigned index, Setter,
423 void set(VM &, const VarStyleObj *, FOTBuilder &,
424 ELObj *&value, Vector<size_t> &dependencies) const;
425 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
430 ExtensionIntegerInheritedC
431 ::ExtensionIntegerInheritedC(const Identifier *ident, unsigned index,
432 Setter setter, long n)
433 : IntegerInheritedC(ident, index, n), setter_(setter)
437 void ExtensionIntegerInheritedC::set(VM &, const VarStyleObj *,
440 Vector<size_t> &) const
442 fotb.extensionSet(setter_, n_);
446 ExtensionIntegerInheritedC::make(ELObj *obj, const Location &loc,
447 Interpreter &interp) const
450 if (interp.convertIntegerC(obj, identifier(), loc, n))
451 return new ExtensionIntegerInheritedC(identifier(), index(), setter_, n);
452 return ConstPtr<InheritedC>();
455 class ExtensionLengthInheritedC : public LengthInheritedC {
457 typedef void (FOTBuilder::*Setter)(FOTBuilder::Length);
458 ExtensionLengthInheritedC(const Identifier *, unsigned index, Setter, FOTBuilder::Length = 0);
459 void set(VM &, const VarStyleObj *, FOTBuilder &,
460 ELObj *&value, Vector<size_t> &dependencies) const;
461 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
466 ExtensionLengthInheritedC
467 ::ExtensionLengthInheritedC(const Identifier *ident, unsigned index,
468 Setter setter, FOTBuilder::Length n)
469 : LengthInheritedC(ident, index, n), setter_(setter)
473 void ExtensionLengthInheritedC::set(VM &, const VarStyleObj *,
476 Vector<size_t> &) const
478 fotb.extensionSet(setter_, size_);
482 ExtensionLengthInheritedC::make(ELObj *obj, const Location &loc,
483 Interpreter &interp) const
485 FOTBuilder::Length n;
486 if (interp.convertLengthC(obj, identifier(), loc, n))
487 return new ExtensionLengthInheritedC(identifier(), index(), setter_, n);
488 return ConstPtr<InheritedC>();
491 class GenericLengthInheritedC : public LengthInheritedC {
493 typedef void (FOTBuilder::*Setter)(FOTBuilder::Length);
494 GenericLengthInheritedC(const Identifier *, unsigned index, Setter,
495 FOTBuilder::Length = 0);
496 void set(VM &, const VarStyleObj *, FOTBuilder &,
497 ELObj *&value, Vector<size_t> &dependencies) const;
498 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
503 GenericLengthInheritedC
504 ::GenericLengthInheritedC(const Identifier *ident, unsigned index,
505 Setter setter, FOTBuilder::Length n)
506 : LengthInheritedC(ident, index, n), setter_(setter)
510 void GenericLengthInheritedC::set(VM &, const VarStyleObj *,
513 Vector<size_t> &) const
515 (fotb.*setter_)(size_);
519 GenericLengthInheritedC::make(ELObj *obj, const Location &loc,
520 Interpreter &interp) const
522 FOTBuilder::Length n;
523 if (interp.convertLengthC(obj, identifier(), loc, n))
524 return new GenericLengthInheritedC(identifier(), index(), setter_, n);
525 return ConstPtr<InheritedC>();
528 class GenericIntegerInheritedC : public IntegerInheritedC {
530 typedef void (FOTBuilder::*Setter)(long);
531 GenericIntegerInheritedC(const Identifier *, unsigned index, Setter, long);
532 void set(VM &, const VarStyleObj *, FOTBuilder &,
533 ELObj *&value, Vector<size_t> &dependencies) const;
534 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
539 GenericIntegerInheritedC
540 ::GenericIntegerInheritedC(const Identifier *ident, unsigned index,
541 Setter setter, long n)
542 : IntegerInheritedC(ident, index, n), setter_(setter)
546 void GenericIntegerInheritedC::set(VM &, const VarStyleObj *,
549 Vector<size_t> &) const
555 GenericIntegerInheritedC::make(ELObj *obj, const Location &loc,
556 Interpreter &interp) const
559 if (interp.convertIntegerC(obj, identifier(), loc, n))
560 return new GenericIntegerInheritedC(identifier(), index(), setter_, n);
561 return ConstPtr<InheritedC>();
564 class GenericMaybeIntegerInheritedC : public GenericIntegerInheritedC {
566 GenericMaybeIntegerInheritedC(const Identifier *, unsigned index,
568 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
569 ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const;
572 GenericMaybeIntegerInheritedC
573 ::GenericMaybeIntegerInheritedC(const Identifier *ident, unsigned index,
574 Setter setter, long n)
575 : GenericIntegerInheritedC(ident, index, setter, n)
579 ELObj *GenericMaybeIntegerInheritedC::value(VM &vm, const VarStyleObj *style,
580 Vector<size_t> &dep) const
583 return vm.interp->makeFalse();
585 return IntegerInheritedC::value(vm, style, dep);
589 GenericMaybeIntegerInheritedC::make(ELObj *obj, const Location &loc,
590 Interpreter &interp) const
593 if (interp.convertOptPositiveIntegerC(obj, identifier(), loc, n))
594 return new GenericMaybeIntegerInheritedC(identifier(), index(),
596 return ConstPtr<InheritedC>();
599 class GenericSymbolInheritedC : public SymbolInheritedC {
601 typedef void (FOTBuilder::*Setter)(FOTBuilder::Symbol);
602 GenericSymbolInheritedC(const Identifier *, unsigned index, Setter,
603 FOTBuilder::Symbol = FOTBuilder::symbolFalse);
604 void set(VM &, const VarStyleObj *, FOTBuilder &,
605 ELObj *&value, Vector<size_t> &dependencies) const;
606 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
611 GenericSymbolInheritedC
612 ::GenericSymbolInheritedC(const Identifier *ident, unsigned index,
613 Setter setter, FOTBuilder::Symbol sym)
614 : SymbolInheritedC(ident, index, sym), setter_(setter)
618 void GenericSymbolInheritedC::set(VM &, const VarStyleObj *,
621 Vector<size_t> &) const
623 (fotb.*setter_)(sym_);
627 GenericSymbolInheritedC::make(ELObj *obj, const Location &loc,
628 Interpreter &interp) const
630 FOTBuilder::Symbol sym;
631 if (interp.convertEnumC(obj, identifier(), loc, sym))
632 return new GenericSymbolInheritedC(identifier(), index(), setter_, sym);
633 return ConstPtr<InheritedC>();
636 class GenericPublicIdInheritedC : public PublicIdInheritedC {
638 typedef void (FOTBuilder::*Setter)(FOTBuilder::PublicId);
639 GenericPublicIdInheritedC(const Identifier *, unsigned index, Setter,
640 FOTBuilder::PublicId = 0);
641 void set(VM &, const VarStyleObj *, FOTBuilder &,
642 ELObj *&value, Vector<size_t> &dependencies) const;
643 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
648 GenericPublicIdInheritedC
649 ::GenericPublicIdInheritedC(const Identifier *ident, unsigned index,
650 Setter setter, FOTBuilder::PublicId pubid)
651 : PublicIdInheritedC(ident, index, pubid), setter_(setter)
655 void GenericPublicIdInheritedC::set(VM &, const VarStyleObj *,
658 Vector<size_t> &) const
660 (fotb.*setter_)(pubid_);
664 GenericPublicIdInheritedC::make(ELObj *obj, const Location &loc,
665 Interpreter &interp) const
667 FOTBuilder::PublicId pubid;
668 if (interp.convertPublicIdC(obj, identifier(), loc, pubid))
669 return new GenericPublicIdInheritedC(identifier(), index(), setter_,
671 return ConstPtr<InheritedC>();
674 class GenericLetter2InheritedC : public Letter2InheritedC {
676 typedef void (FOTBuilder::*Setter)(FOTBuilder::Letter2);
677 GenericLetter2InheritedC(const Identifier *, unsigned index, Setter,
678 FOTBuilder::Letter2 = 0);
679 void set(VM &, const VarStyleObj *, FOTBuilder &,
680 ELObj *&value, Vector<size_t> &dependencies) const;
681 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
686 GenericLetter2InheritedC
687 ::GenericLetter2InheritedC(const Identifier *ident, unsigned index,
688 Setter setter, FOTBuilder::Letter2 code)
689 : Letter2InheritedC(ident, index, code), setter_(setter)
693 void GenericLetter2InheritedC::set(VM &, const VarStyleObj *,
696 Vector<size_t> &) const
698 (fotb.*setter_)(code_);
702 GenericLetter2InheritedC::make(ELObj *obj, const Location &loc,
703 Interpreter &interp) const
705 FOTBuilder::Letter2 code;
706 if (interp.convertLetter2C(obj, identifier(), loc, code))
707 return new GenericLetter2InheritedC(identifier(), index(), setter_, code);
708 return ConstPtr<InheritedC>();
711 class GenericLengthSpecInheritedC : public LengthSpecInheritedC {
713 typedef void (FOTBuilder::*Setter)(const FOTBuilder::LengthSpec &);
714 GenericLengthSpecInheritedC(const Identifier *, unsigned index, Setter,
716 void set(VM &, const VarStyleObj *, FOTBuilder &,
717 ELObj *&value, Vector<size_t> &dependencies) const;
718 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
723 GenericLengthSpecInheritedC
724 ::GenericLengthSpecInheritedC(const Identifier *ident, unsigned index,
725 Setter setter, long n)
726 : LengthSpecInheritedC(ident, index, n), setter_(setter)
730 void GenericLengthSpecInheritedC::set(VM &, const VarStyleObj *,
733 Vector<size_t> &) const
735 (fotb.*setter_)(value_);
739 GenericLengthSpecInheritedC::make(ELObj *obj, const Location &loc,
740 Interpreter &interp) const
742 GenericLengthSpecInheritedC *copy
743 = new GenericLengthSpecInheritedC(identifier(), index(), setter_);
744 if (!copy->setValue(obj, loc, interp)) {
751 class GenericOptInlineSpaceInheritedC : public InheritedC {
753 typedef void (FOTBuilder::*Setter)(const FOTBuilder::OptInlineSpace &);
754 GenericOptInlineSpaceInheritedC(const Identifier *, unsigned index, Setter);
755 ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const;
756 void set(VM &, const VarStyleObj *, FOTBuilder &,
757 ELObj *&value, Vector<size_t> &dependencies) const;
758 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
760 FOTBuilder::OptInlineSpace value_;
764 GenericOptInlineSpaceInheritedC
765 ::GenericOptInlineSpaceInheritedC(const Identifier *ident, unsigned index,
767 : InheritedC(ident, index), setter_(setter)
771 ELObj *GenericOptInlineSpaceInheritedC::value(VM &vm, const VarStyleObj *,
772 Vector<size_t> &) const
774 if (!value_.hasSpace)
775 return vm.interp->makeFalse();
777 return new (*vm.interp) InlineSpaceObj(value_.space);
781 void GenericOptInlineSpaceInheritedC::set(VM &, const VarStyleObj *,
784 Vector<size_t> &) const
786 (fotb.*setter_)(value_);
790 GenericOptInlineSpaceInheritedC::make(ELObj *obj, const Location &loc,
791 Interpreter &interp) const
793 GenericOptInlineSpaceInheritedC *copy
794 = new GenericOptInlineSpaceInheritedC(identifier(), index(), setter_);
795 InlineSpaceObj *iso = obj->asInlineSpace();
797 copy->value_.space = iso->inlineSpace();
798 copy->value_.hasSpace = 1;
801 FOTBuilder::OptLengthSpec res;
802 if (interp.convertOptLengthSpecC(obj, identifier(), loc, res)) {
804 copy->value_.space.nominal = res.length;
805 copy->value_.space.min = res.length;
806 copy->value_.space.max = res.length;
807 copy->value_.hasSpace = 1;
809 copy->value_.hasSpace = 0;
819 class GenericOptLengthSpecInheritedC : public OptLengthSpecInheritedC {
821 typedef void (FOTBuilder::*Setter)(const FOTBuilder::OptLengthSpec &);
822 GenericOptLengthSpecInheritedC(const Identifier *, unsigned index, Setter);
823 void set(VM &, const VarStyleObj *, FOTBuilder &,
824 ELObj *&value, Vector<size_t> &dependencies) const;
825 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
830 GenericOptLengthSpecInheritedC
831 ::GenericOptLengthSpecInheritedC(const Identifier *ident, unsigned index,
833 : OptLengthSpecInheritedC(ident, index), setter_(setter)
837 void GenericOptLengthSpecInheritedC::set(VM &, const VarStyleObj *,
840 Vector<size_t> &) const
842 (fotb.*setter_)(value_);
846 GenericOptLengthSpecInheritedC::make(ELObj *obj, const Location &loc,
847 Interpreter &interp) const
849 GenericOptLengthSpecInheritedC *copy
850 = new GenericOptLengthSpecInheritedC(identifier(), index(), setter_);
851 if (!copy->setValue(obj, loc, interp)) {
858 class FontSizeC : public LengthInheritedC {
860 FontSizeC(const Identifier *, unsigned index, long);
861 void set(VM &, const VarStyleObj *, FOTBuilder &,
862 ELObj *&value, Vector<size_t> &dependencies) const;
863 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
866 FontSizeC::FontSizeC(const Identifier *ident, unsigned index, long size)
867 : LengthInheritedC(ident, index, size)
871 void FontSizeC::set(VM &vm, const VarStyleObj *, FOTBuilder &fotb, ELObj *&,
872 Vector<size_t> &) const
874 fotb.setFontSize(size_);
877 ConstPtr<InheritedC> FontSizeC::make(ELObj *obj, const Location &loc,
878 Interpreter &interp) const
881 if (interp.convertLengthC(obj, identifier(), loc, n))
882 return new FontSizeC(identifier(), index(), n);
883 return ConstPtr<InheritedC>();
886 class FontFamilyNameC : public StringInheritedC {
888 FontFamilyNameC(const Identifier *, unsigned index, const Char *, size_t);
889 FontFamilyNameC(const Identifier *, unsigned index, const StringC &);
890 void set(VM &, const VarStyleObj *, FOTBuilder &,
891 ELObj *&value, Vector<size_t> &dependencies) const;
892 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
895 FontFamilyNameC::FontFamilyNameC(const Identifier *ident, unsigned index, const Char *s, size_t n)
896 : StringInheritedC(ident, index, s, n)
900 FontFamilyNameC::FontFamilyNameC(const Identifier *ident, unsigned index, const StringC &s)
901 : StringInheritedC(ident, index, s)
905 void FontFamilyNameC::set(VM &vm, const VarStyleObj *, FOTBuilder &fotb, ELObj *&,
906 Vector<size_t> &) const
908 fotb.setFontFamilyName(str_);
911 ConstPtr<InheritedC> FontFamilyNameC::make(ELObj *obj, const Location &loc,
912 Interpreter &interp) const
916 if (obj->stringData(s, n))
917 return new FontFamilyNameC(identifier(), index(), s, n);
918 invalidValue(loc, interp);
919 return ConstPtr<InheritedC>();
922 class ColorC : public InheritedC, private Collector::DynamicRoot {
924 ColorC(const Identifier *, unsigned index, ColorObj *, Interpreter &);
925 void set(VM &, const VarStyleObj *, FOTBuilder &,
926 ELObj *&value, Vector<size_t> &dependencies) const;
927 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
928 ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const;
929 void trace(Collector &) const;
934 ColorC::ColorC(const Identifier *ident, unsigned index, ColorObj *color,
936 : InheritedC(ident, index), Collector::DynamicRoot(interp), color_(color)
940 void ColorC::set(VM &, const VarStyleObj *, FOTBuilder &fotb,
941 ELObj *&, Vector<size_t> &) const
946 ConstPtr<InheritedC> ColorC::make(ELObj *obj, const Location &loc,
947 Interpreter &interp) const
950 if (interp.convertColorC(obj, identifier(), loc, color))
951 return new ColorC(identifier(), index(), color, interp);
952 return ConstPtr<InheritedC>();
955 ELObj *ColorC::value(VM &vm, const VarStyleObj *, Vector<size_t> &) const
958 return vm.interp->makeFalse();
963 void ColorC::trace(Collector &c) const
968 class BackgroundColorC : public InheritedC, private Collector::DynamicRoot {
970 BackgroundColorC(const Identifier *, unsigned index, ColorObj *,
972 void set(VM &, const VarStyleObj *, FOTBuilder &,
973 ELObj *&value, Vector<size_t> &dependencies) const;
974 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
975 ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const;
976 void trace(Collector &) const;
981 BackgroundColorC::BackgroundColorC(const Identifier *ident, unsigned index,
982 ColorObj *color, Interpreter &interp)
983 : InheritedC(ident, index), Collector::DynamicRoot(interp), color_(color)
987 void BackgroundColorC::set(VM &, const VarStyleObj *, FOTBuilder &fotb,
988 ELObj *&, Vector<size_t> &) const
991 color_->setBackground(fotb);
993 fotb.setBackgroundColor();
996 ConstPtr<InheritedC> BackgroundColorC::make(ELObj *obj, const Location &loc,
997 Interpreter &interp) const
1000 if (interp.convertOptColorC(obj, identifier(), loc, color))
1001 return new BackgroundColorC(identifier(), index(), color, interp);
1002 return ConstPtr<InheritedC>();
1006 BackgroundColorC::value(VM &vm, const VarStyleObj *, Vector<size_t> &) const
1011 return vm.interp->makeFalse();
1014 void BackgroundColorC::trace(Collector &c) const
1019 class GlyphSubstTableC : public InheritedC {
1021 GlyphSubstTableC(const Identifier *, unsigned index, bool isList);
1022 void set(VM &, const VarStyleObj *, FOTBuilder &,
1023 ELObj *&value, Vector<size_t> &dependencies) const;
1024 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
1025 ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const;
1026 void append(const ConstPtr<FOTBuilder::GlyphSubstTable> &table) { tables_.push_back(table); }
1028 // Distinguish between #f and () for inherited-glyph-subst-table
1030 Vector<ConstPtr<FOTBuilder::GlyphSubstTable> > tables_;
1033 GlyphSubstTableC::GlyphSubstTableC(const Identifier *ident, unsigned index, bool isList)
1034 : InheritedC(ident, index), isList_(isList)
1038 void GlyphSubstTableC::set(VM &, const VarStyleObj *, FOTBuilder &fotb,
1039 ELObj *&, Vector<size_t> &) const
1041 fotb.setGlyphSubstTable(tables_);
1044 ConstPtr<InheritedC> GlyphSubstTableC::make(ELObj *obj, const Location &loc,
1045 Interpreter &interp) const
1047 if (obj == interp.makeFalse())
1048 return new GlyphSubstTableC(identifier(), index(), 0);
1049 GlyphSubstTableObj *table = obj->asGlyphSubstTable();
1051 Ptr<InheritedC> tem = new GlyphSubstTableC(identifier(), index(), 0);
1052 ((GlyphSubstTableC *)tem.pointer())->append(table->glyphSubstTable());
1055 Ptr<InheritedC> tem = new GlyphSubstTableC(identifier(), index(), 1);
1059 PairObj *pair = obj->asPair();
1063 table = pair->car()->asGlyphSubstTable();
1066 ((GlyphSubstTableC *)tem.pointer())->append(table->glyphSubstTable());
1068 invalidValue(loc, interp);
1069 return ConstPtr<InheritedC>();
1072 ELObj *GlyphSubstTableC::value(VM &vm, const VarStyleObj *, Vector<size_t> &) const
1076 return new (*vm.interp) GlyphSubstTableObj(tables_[0]);
1078 return vm.interp->makeFalse();
1081 ELObj *list = vm.interp->makeNil();
1082 ELObjDynamicRoot protect(*vm.interp, list);
1083 for (size_t i = tables_.size(); i > 0; i--) {
1084 ELObj *tableObj = new (*vm.interp) GlyphSubstTableObj(tables_[i - 1]);
1085 ELObjDynamicRoot protect2(*vm.interp, tableObj);
1086 list = vm.interp->makePair(tableObj, list);
1093 class IgnoredC : public InheritedC, private Collector::DynamicRoot {
1095 IgnoredC(const Identifier *, unsigned index, ELObj *, Interpreter &);
1096 void set(VM &, const VarStyleObj *, FOTBuilder &,
1097 ELObj *&, Vector<size_t> &) const;
1098 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
1099 ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const;
1100 void trace(Collector &) const;
1106 IgnoredC::IgnoredC(const Identifier *ident, unsigned index, ELObj *value, Interpreter &interp)
1107 : InheritedC(ident, index), Collector::DynamicRoot(interp), value_(value)
1111 void IgnoredC::set(VM &, const VarStyleObj *, FOTBuilder &fotb,
1112 ELObj *&, Vector<size_t> &) const
1116 ConstPtr<InheritedC> IgnoredC::make(ELObj *obj, const Location &, Interpreter &interp) const
1118 return new IgnoredC(identifier(), index(), obj, interp);
1121 ELObj *IgnoredC::value(VM &, const VarStyleObj *, Vector<size_t> &) const
1126 void IgnoredC::trace(Collector &c) const
1131 class BorderC : public IgnoredC {
1133 BorderC(const Identifier *, unsigned index, ELObj *, Interpreter &);
1134 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
1137 BorderC::BorderC(const Identifier *ident, unsigned index, ELObj *value, Interpreter &interp)
1138 : IgnoredC(ident, index, value, interp)
1142 ConstPtr<InheritedC> BorderC::make(ELObj *obj, const Location &loc, Interpreter &interp) const
1145 SosofoObj *sosofo = obj->asSosofo();
1146 if (sosofo && sosofo->tableBorderStyle(tem))
1147 return new BorderC(identifier(), index(), obj, interp);
1149 if (interp.convertBooleanC(obj, identifier(), loc, b)) {
1151 obj = interp.makeTrue();
1153 obj = interp.makeFalse();
1154 return new BorderC(identifier(), index(), obj, interp);
1156 return ConstPtr<InheritedC>();
1159 class RuleC : public IgnoredC {
1161 RuleC(const Identifier *, unsigned index, ELObj *, Interpreter &);
1162 ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const;
1165 RuleC::RuleC(const Identifier *ident, unsigned index, ELObj *value, Interpreter &interp)
1166 : IgnoredC(ident, index, value, interp)
1170 ConstPtr<InheritedC> RuleC::make(ELObj *obj, const Location &loc, Interpreter &interp) const
1172 SosofoObj *sosofo = obj->asSosofo();
1173 if (sosofo && sosofo->isRule())
1174 return new RuleC(identifier(), index(), obj, interp);
1175 invalidValue(loc, interp);
1176 return ConstPtr<InheritedC>();
1179 class InheritedCPrimitiveObj : public PrimitiveObj {
1181 void *operator new(size_t, Collector &c) {
1182 return c.allocateObject(1);
1184 static const Signature signature_;
1185 InheritedCPrimitiveObj(const ConstPtr<InheritedC> &ic)
1186 : PrimitiveObj(&signature_), inheritedC_(ic) { }
1187 ELObj *primitiveCall(int, ELObj **, EvalContext &, Interpreter &, const Location &);
1189 ConstPtr<InheritedC> inheritedC_;
1192 const Signature InheritedCPrimitiveObj::signature_ = { 0, 0, 0 };
1194 ELObj *InheritedCPrimitiveObj::primitiveCall(int, ELObj **, EvalContext &ec,
1195 Interpreter &interp,
1196 const Location &loc)
1198 if (!ec.styleStack) {
1199 interp.setNextLocation(loc);
1200 interp.message(InterpreterMessages::notInCharacteristicValue);
1201 return interp.makeError();
1203 ELObj *obj = ec.styleStack->inherited(inheritedC_, ec.specLevel, interp,
1204 *ec.actualDependencies);
1205 interp.makeReadOnly(obj);
1209 class ActualCPrimitiveObj : public PrimitiveObj {
1211 void *operator new(size_t, Collector &c) {
1212 return c.allocateObject(1);
1214 static const Signature signature_;
1215 ActualCPrimitiveObj(const ConstPtr<InheritedC> &ic)
1216 : PrimitiveObj(&signature_), inheritedC_(ic) { }
1217 ELObj *primitiveCall(int, ELObj **, EvalContext &, Interpreter &, const Location &);
1219 ConstPtr<InheritedC> inheritedC_;
1222 const Signature ActualCPrimitiveObj::signature_ = { 0, 0, 0 };
1224 ELObj *ActualCPrimitiveObj::primitiveCall(int, ELObj **, EvalContext &ec, Interpreter &interp,
1225 const Location &loc)
1227 if (!ec.styleStack) {
1228 interp.setNextLocation(loc);
1229 interp.message(InterpreterMessages::notInCharacteristicValue);
1230 return interp.makeError();
1232 ELObj *obj = ec.styleStack->actual(inheritedC_, loc, interp, *ec.actualDependencies);
1235 interp.makeReadOnly(obj);
1239 #define INHERITED_C(name, C, init) \
1240 installInheritedC(name, new C(0, nInheritedC_++, init))
1241 #define INHERITED_C2(name, C, init1, init2) \
1242 installInheritedC(name, new C(0, nInheritedC_++, init1, init2))
1243 #define STORE_INHERITED_C2(var, name, C, init1, init2) \
1244 { InheritedC *ic = new C(0, nInheritedC_++, init1, init2); \
1245 installInheritedC(name, ic); \
1248 #define IGNORED_C(name, init) INHERITED_C2(name, IgnoredC, init, *this)
1250 static StyleObj *makeBorderStyle(bool b, unsigned index, Interpreter &interp)
1252 Vector<ConstPtr<InheritedC> > forceSpecs;
1253 Vector<ConstPtr<InheritedC> > specs;
1255 new GenericBoolInheritedC(interp.lookup(interp.makeStringC("border-present?")),
1256 index, &FOTBuilder::setBorderPresent, b));
1259 = new (interp) VarStyleObj(new StyleSpec(forceSpecs, specs), 0, 0, NodePtr());
1260 interp.makePermanent(style);
1264 void Interpreter::installInheritedCs()
1266 INHERITED_C("font-size", FontSizeC, (unitsPerInch()*10)/72);
1267 INHERITED_C("font-family-name", FontFamilyNameC, makeStringC("iso-serif"));
1268 INHERITED_C2("font-weight", GenericSymbolInheritedC, &FOTBuilder::setFontWeight,
1269 FOTBuilder::symbolMedium);
1270 INHERITED_C2("font-posture", GenericSymbolInheritedC, &FOTBuilder::setFontPosture,
1271 FOTBuilder::symbolUpright);
1272 INHERITED_C2("quadding", GenericSymbolInheritedC, &FOTBuilder::setQuadding,
1273 FOTBuilder::symbolStart);
1274 INHERITED_C2("display-alignment", GenericSymbolInheritedC, &FOTBuilder::setDisplayAlignment,
1275 FOTBuilder::symbolStart);
1276 INHERITED_C2("field-align", GenericSymbolInheritedC, &FOTBuilder::setFieldAlign,
1277 FOTBuilder::symbolStart);
1278 INHERITED_C2("lines", GenericSymbolInheritedC, &FOTBuilder::setLines, FOTBuilder::symbolWrap);
1279 INHERITED_C("start-indent", GenericLengthSpecInheritedC,
1280 &FOTBuilder::setStartIndent);
1281 INHERITED_C("first-line-start-indent", GenericLengthSpecInheritedC,
1282 &FOTBuilder::setFirstLineStartIndent);
1283 INHERITED_C("end-indent", GenericLengthSpecInheritedC,
1284 &FOTBuilder::setEndIndent);
1285 INHERITED_C("last-line-end-indent", GenericLengthSpecInheritedC,
1286 &FOTBuilder::setLastLineEndIndent);
1287 INHERITED_C2("line-spacing", GenericLengthSpecInheritedC,
1288 &FOTBuilder::setLineSpacing, unitsPerInch()*12/72);
1289 INHERITED_C("field-width", GenericLengthSpecInheritedC,
1290 &FOTBuilder::setFieldWidth);
1291 INHERITED_C("left-margin", GenericLengthInheritedC,
1292 &FOTBuilder::setLeftMargin);
1293 INHERITED_C("right-margin", GenericLengthInheritedC,
1294 &FOTBuilder::setRightMargin);
1295 INHERITED_C("top-margin", GenericLengthInheritedC,
1296 &FOTBuilder::setTopMargin);
1297 INHERITED_C("bottom-margin", GenericLengthInheritedC,
1298 &FOTBuilder::setBottomMargin);
1299 INHERITED_C("header-margin", GenericLengthInheritedC,
1300 &FOTBuilder::setHeaderMargin);
1301 INHERITED_C("footer-margin", GenericLengthInheritedC,
1302 &FOTBuilder::setFooterMargin);
1303 INHERITED_C2("page-width", GenericLengthInheritedC,
1304 &FOTBuilder::setPageWidth,
1305 unitsPerInch()*8 + unitsPerInch()/2);
1306 INHERITED_C2("page-height", GenericLengthInheritedC,
1307 &FOTBuilder::setPageHeight,
1309 INHERITED_C2("color", ColorC, new (*this) DeviceRGBColorObj(0, 0, 0), *this);
1310 INHERITED_C2("background-color", BackgroundColorC, 0, *this);
1311 INHERITED_C2("border-present?", GenericBoolInheritedC,
1312 &FOTBuilder::setBorderPresent, 1);
1313 borderTrueStyle_ = makeBorderStyle(1, nInheritedC_ - 1, *this);
1314 borderFalseStyle_ = makeBorderStyle(0, nInheritedC_ - 1, *this);
1315 STORE_INHERITED_C2(tableBorderC_, "table-border", BorderC, makeFalse(), *this);
1316 STORE_INHERITED_C2(cellBeforeRowBorderC_, "cell-before-row-border",
1317 BorderC, makeFalse(), *this);
1318 STORE_INHERITED_C2(cellAfterRowBorderC_, "cell-after-row-border",
1319 BorderC, makeFalse(), *this);
1320 STORE_INHERITED_C2(cellBeforeColumnBorderC_, "cell-before-column-border",
1321 BorderC, makeFalse(), *this);
1322 STORE_INHERITED_C2(cellAfterColumnBorderC_, "cell-after-column-border",
1323 BorderC, makeFalse(), *this);
1324 STORE_INHERITED_C2(fractionBarC_, "fraction-bar",
1325 RuleC, lookup(makeStringC("rule"))->flowObj(), *this);
1326 INHERITED_C2("line-thickness", GenericLengthInheritedC, &FOTBuilder::setLineThickness,
1328 INHERITED_C2("cell-before-row-margin", GenericLengthInheritedC,
1329 &FOTBuilder::setCellBeforeRowMargin, 0);
1330 INHERITED_C2("cell-after-row-margin", GenericLengthInheritedC,
1331 &FOTBuilder::setCellAfterRowMargin, 0);
1332 INHERITED_C2("cell-before-column-margin", GenericLengthInheritedC,
1333 &FOTBuilder::setCellBeforeColumnMargin, 0);
1334 INHERITED_C2("cell-after-column-margin", GenericLengthInheritedC,
1335 &FOTBuilder::setCellAfterColumnMargin, 0);
1336 INHERITED_C2("line-sep", GenericLengthInheritedC,
1337 &FOTBuilder::setLineSep, unitsPerInch()/72);
1338 INHERITED_C2("box-size-before", GenericLengthInheritedC, &FOTBuilder::setBoxSizeBefore,
1339 8*unitsPerInch()/72);
1340 INHERITED_C2("box-size-after", GenericLengthInheritedC, &FOTBuilder::setBoxSizeAfter,
1341 4*unitsPerInch()/72);
1342 INHERITED_C2("position-point-shift", GenericLengthSpecInheritedC,
1343 &FOTBuilder::setPositionPointShift, 0);
1344 INHERITED_C2("start-margin", GenericLengthSpecInheritedC, &FOTBuilder::setStartMargin, 0);
1345 INHERITED_C2("end-margin", GenericLengthSpecInheritedC, &FOTBuilder::setEndMargin, 0);
1346 INHERITED_C2("sideline-sep", GenericLengthSpecInheritedC, &FOTBuilder::setSidelineSep,
1347 4*unitsPerInch()/72);
1348 INHERITED_C2("asis-wrap-indent", GenericLengthSpecInheritedC, &FOTBuilder::setAsisWrapIndent, 0);
1349 INHERITED_C2("line-number-sep", GenericLengthSpecInheritedC, &FOTBuilder::setLineNumberSep, 0);
1350 INHERITED_C2("last-line-justify-limit", GenericLengthSpecInheritedC,
1351 &FOTBuilder::setLastLineJustifyLimit, 0);
1352 INHERITED_C2("justify-glyph-space-max-add", GenericLengthSpecInheritedC,
1353 &FOTBuilder::setJustifyGlyphSpaceMaxAdd, 0);
1354 INHERITED_C2("justify-glyph-space-max-remove", GenericLengthSpecInheritedC,
1355 &FOTBuilder::setJustifyGlyphSpaceMaxRemove, 0);
1356 INHERITED_C2("table-corner-radius", GenericLengthSpecInheritedC,
1357 &FOTBuilder::setTableCornerRadius, 3*unitsPerInch()/72);
1358 INHERITED_C2("box-corner-radius", GenericLengthSpecInheritedC,
1359 &FOTBuilder::setBoxCornerRadius, 3*unitsPerInch()/72);
1360 INHERITED_C2("marginalia-sep", GenericLengthSpecInheritedC,
1361 &FOTBuilder::setMarginaliaSep, 0);
1362 INHERITED_C2("inhibit-line-breaks?", GenericBoolInheritedC, &FOTBuilder::setInhibitLineBreaks, 0);
1363 INHERITED_C2("hyphenate?", GenericBoolInheritedC, &FOTBuilder::setHyphenate, 0);
1364 INHERITED_C2("kern?", GenericBoolInheritedC, &FOTBuilder::setKern, 0);
1365 INHERITED_C2("ligature?", GenericBoolInheritedC, &FOTBuilder::setLigature, 0);
1366 INHERITED_C2("score-spaces?", GenericBoolInheritedC, &FOTBuilder::setScoreSpaces, 0);
1367 INHERITED_C2("float-out-sidelines?", GenericBoolInheritedC, &FOTBuilder::setFloatOutSidelines, 0);
1368 INHERITED_C2("float-out-marginalia?", GenericBoolInheritedC, &FOTBuilder::setFloatOutMarginalia, 0);
1369 INHERITED_C2("float-out-line-numbers?", GenericBoolInheritedC, &FOTBuilder::setFloatOutLineNumbers, 0);
1370 INHERITED_C2("cell-background?", GenericBoolInheritedC, &FOTBuilder::setCellBackground, 0);
1371 INHERITED_C2("span-weak?", GenericBoolInheritedC, &FOTBuilder::setSpanWeak, 0);
1372 INHERITED_C2("ignore-record-end?", GenericBoolInheritedC, &FOTBuilder::setIgnoreRecordEnd, 0);
1373 INHERITED_C2("numbered-lines?", GenericBoolInheritedC, &FOTBuilder::setNumberedLines, 1);
1374 INHERITED_C2("hanging-punct?", GenericBoolInheritedC, &FOTBuilder::setHangingPunct, 0);
1375 INHERITED_C2("box-open-end?", GenericBoolInheritedC, &FOTBuilder::setBoxOpenEnd, 0);
1376 INHERITED_C2("truncate-leader?", GenericBoolInheritedC, &FOTBuilder::setTruncateLeader, 0);
1377 INHERITED_C2("align-leader?", GenericBoolInheritedC, &FOTBuilder::setAlignLeader, 1);
1378 INHERITED_C2("table-part-omit-middle-header?", GenericBoolInheritedC,
1379 &FOTBuilder::setTablePartOmitMiddleHeader, 0);
1380 INHERITED_C2("table-part-omit-middle-footer?", GenericBoolInheritedC,
1381 &FOTBuilder::setTablePartOmitMiddleFooter, 0);
1382 INHERITED_C2("border-omit-at-break?", GenericBoolInheritedC, &FOTBuilder::setBorderOmitAtBreak, 0);
1383 INHERITED_C2("principal-mode-simultaneous?", GenericBoolInheritedC,
1384 &FOTBuilder::setPrincipalModeSimultaneous, 0);
1385 INHERITED_C2("marginalia-keep-with-previous?", GenericBoolInheritedC,
1386 &FOTBuilder::setMarginaliaKeepWithPrevious, 0);
1387 INHERITED_C2("grid-equidistant-rows?", GenericBoolInheritedC, &FOTBuilder::setGridEquidistantRows, 0);
1388 INHERITED_C2("grid-equidistant-columns?", GenericBoolInheritedC, &FOTBuilder::setGridEquidistantColumns, 0);
1389 INHERITED_C2("line-join", GenericSymbolInheritedC, &FOTBuilder::setLineJoin,
1390 FOTBuilder::symbolMiter);
1391 INHERITED_C2("line-cap", GenericSymbolInheritedC, &FOTBuilder::setLineCap,
1392 FOTBuilder::symbolButt);
1393 INHERITED_C2("line-number-side", GenericSymbolInheritedC, &FOTBuilder::setLineNumberSide,
1394 FOTBuilder::symbolStart);
1395 INHERITED_C2("kern-mode", GenericSymbolInheritedC, &FOTBuilder::setKernMode,
1396 FOTBuilder::symbolNormal);
1397 INHERITED_C2("input-whitespace-treatment", GenericSymbolInheritedC,
1398 &FOTBuilder::setInputWhitespaceTreatment, FOTBuilder::symbolPreserve);
1399 INHERITED_C2("filling-direction", GenericSymbolInheritedC, &FOTBuilder::setFillingDirection,
1400 FOTBuilder::symbolTopToBottom );
1401 INHERITED_C2("writing-mode", GenericSymbolInheritedC, &FOTBuilder::setWritingMode,
1402 FOTBuilder::symbolLeftToRight );
1403 INHERITED_C2("last-line-quadding", GenericSymbolInheritedC, &FOTBuilder::setLastLineQuadding,
1404 FOTBuilder::symbolRelative);
1405 INHERITED_C2("math-display-mode", GenericSymbolInheritedC, &FOTBuilder::setMathDisplayMode,
1406 FOTBuilder::symbolDisplay);
1407 INHERITED_C2("script-pre-align", GenericSymbolInheritedC, &FOTBuilder::setScriptPreAlign,
1408 FOTBuilder::symbolIndependent);
1409 INHERITED_C2("script-post-align", GenericSymbolInheritedC, &FOTBuilder::setScriptPostAlign,
1410 FOTBuilder::symbolIndependent);
1411 INHERITED_C2("script-mid-sup-align", GenericSymbolInheritedC, &FOTBuilder::setScriptMidSupAlign,
1412 FOTBuilder::symbolCenter);
1413 INHERITED_C2("script-mid-sub-align", GenericSymbolInheritedC, &FOTBuilder::setScriptMidSubAlign,
1414 FOTBuilder::symbolCenter);
1415 INHERITED_C2("numerator-align", GenericSymbolInheritedC, &FOTBuilder::setNumeratorAlign,
1416 FOTBuilder::symbolCenter);
1417 INHERITED_C2("denominator-align", GenericSymbolInheritedC, &FOTBuilder::setDenominatorAlign,
1418 FOTBuilder::symbolCenter);
1419 INHERITED_C2("grid-position-cell-type", GenericSymbolInheritedC, &FOTBuilder::setGridPositionCellType,
1420 FOTBuilder::symbolRowMajor);
1421 INHERITED_C2("grid-column-alignment", GenericSymbolInheritedC, &FOTBuilder::setGridColumnAlignment,
1422 FOTBuilder::symbolCenter);
1423 INHERITED_C2("grid-row-alignment", GenericSymbolInheritedC, &FOTBuilder::setGridRowAlignment,
1424 FOTBuilder::symbolCenter);
1425 INHERITED_C2("box-type", GenericSymbolInheritedC, &FOTBuilder::setBoxType,
1426 FOTBuilder::symbolBorder);
1427 INHERITED_C2("glyph-alignment-mode", GenericSymbolInheritedC, &FOTBuilder::setGlyphAlignmentMode,
1428 FOTBuilder::symbolFont);
1429 INHERITED_C2("box-border-alignment", GenericSymbolInheritedC, &FOTBuilder::setBoxBorderAlignment,
1430 FOTBuilder::symbolOutside);
1431 INHERITED_C2("cell-row-alignment", GenericSymbolInheritedC, &FOTBuilder::setCellRowAlignment,
1432 FOTBuilder::symbolStart);
1433 INHERITED_C2("border-alignment", GenericSymbolInheritedC, &FOTBuilder::setBorderAlignment,
1434 FOTBuilder::symbolCenter);
1435 INHERITED_C2("sideline-side", GenericSymbolInheritedC, &FOTBuilder::setSidelineSide,
1436 FOTBuilder::symbolStart);
1437 INHERITED_C2("hyphenation-keep", GenericSymbolInheritedC, &FOTBuilder::setHyphenationKeep,
1438 FOTBuilder::symbolFalse);
1439 INHERITED_C2("font-structure", GenericSymbolInheritedC, &FOTBuilder::setFontStructure,
1440 FOTBuilder::symbolSolid);
1441 INHERITED_C2("font-proportionate-width", GenericSymbolInheritedC,
1442 &FOTBuilder::setFontProportionateWidth, FOTBuilder::symbolMedium);
1443 INHERITED_C2("cell-crossed", GenericSymbolInheritedC, &FOTBuilder::setCellCrossed,
1444 FOTBuilder::symbolFalse);
1445 INHERITED_C2("marginalia-side", GenericSymbolInheritedC, &FOTBuilder::setMarginaliaSide,
1446 FOTBuilder::symbolStart);
1447 INHERITED_C2("layer", GenericIntegerInheritedC, &FOTBuilder::setLayer, 0);
1448 INHERITED_C2("background-layer", GenericIntegerInheritedC, &FOTBuilder::setBackgroundLayer, -1);
1449 INHERITED_C2("border-priority", GenericIntegerInheritedC, &FOTBuilder::setBorderPriority, 0);
1450 INHERITED_C2("line-repeat", GenericIntegerInheritedC, &FOTBuilder::setLineRepeat, 1);
1451 INHERITED_C2("span", GenericIntegerInheritedC, &FOTBuilder::setSpan, 1);
1452 INHERITED_C2("min-leader-repeat", GenericIntegerInheritedC, &FOTBuilder::setMinLeaderRepeat, 1);
1453 INHERITED_C2("hyphenation-remain-char-count", GenericIntegerInheritedC,
1454 &FOTBuilder::setHyphenationRemainCharCount, 2);
1455 INHERITED_C2("hyphenation-push-char-count", GenericIntegerInheritedC,
1456 &FOTBuilder::setHyphenationPushCharCount, 2);
1457 INHERITED_C2("widow-count", GenericIntegerInheritedC, &FOTBuilder::setWidowCount, 2);
1458 INHERITED_C2("orphan-count", GenericIntegerInheritedC, &FOTBuilder::setOrphanCount, 2);
1459 // #f or strictly positive integer
1460 INHERITED_C2("expand-tabs?", GenericMaybeIntegerInheritedC,
1461 &FOTBuilder::setExpandTabs, 8);
1462 INHERITED_C2("hyphenation-ladder-count", GenericMaybeIntegerInheritedC,
1463 &FOTBuilder::setHyphenationLadderCount, 0);
1464 INHERITED_C("background-tile", GenericPublicIdInheritedC, &FOTBuilder::setBackgroundTile);
1465 INHERITED_C("line-breaking-method", GenericPublicIdInheritedC, &FOTBuilder::setLineBreakingMethod);
1466 INHERITED_C("line-composition-method", GenericPublicIdInheritedC, &FOTBuilder::setLineCompositionMethod);
1467 INHERITED_C("implicit-bidi-method", GenericPublicIdInheritedC, &FOTBuilder::setImplicitBidiMethod);
1468 INHERITED_C("glyph-subst-method", GenericPublicIdInheritedC, &FOTBuilder::setGlyphSubstMethod);
1469 INHERITED_C("glyph-reorder-method", GenericPublicIdInheritedC, &FOTBuilder::setGlyphReorderMethod);
1470 INHERITED_C("hyphenation-method", GenericPublicIdInheritedC, &FOTBuilder::setHyphenationMethod);
1471 INHERITED_C("table-auto-width-method", GenericPublicIdInheritedC, &FOTBuilder::setTableAutoWidthMethod);
1472 INHERITED_C("font-name", GenericPublicIdInheritedC, &FOTBuilder::setFontName);
1473 // 2 letter symbol or #f
1474 INHERITED_C("language", GenericLetter2InheritedC, &FOTBuilder::setLanguage);
1475 INHERITED_C("country", GenericLetter2InheritedC, &FOTBuilder::setCountry);
1476 // Ignored characteristics
1477 ELObjDynamicRoot length0(*this, new (*this) LengthObj(0));
1478 // #f or length-spec
1479 INHERITED_C("min-pre-line-spacing", GenericOptLengthSpecInheritedC, &FOTBuilder::setMinPreLineSpacing);
1480 INHERITED_C("min-post-line-spacing", GenericOptLengthSpecInheritedC, &FOTBuilder::setMinPostLineSpacing);
1481 INHERITED_C("min-leading", GenericOptLengthSpecInheritedC, &FOTBuilder::setMinLeading);
1483 INHERITED_C("escapement-space-before", GenericInlineSpaceInheritedC, &FOTBuilder::setEscapementSpaceBefore);
1484 INHERITED_C("escapement-space-after", GenericInlineSpaceInheritedC, &FOTBuilder::setEscapementSpaceAfter);
1485 // #f or glyph-subst-table
1486 INHERITED_C("glyph-subst-table", GlyphSubstTableC, 0);
1488 // #f or inline-space
1489 INHERITED_C("inline-space-space", GenericOptInlineSpaceInheritedC, &FOTBuilder::setInlineSpaceSpace);
1492 IGNORED_C("line-miter-limit", makeInteger(10));
1494 IGNORED_C("alignment-point-offset", makeInteger(50));
1496 IGNORED_C("hyphenation-char", new (*this) CharObj('-'));
1498 IGNORED_C("asis-truncate-char", makeFalse());
1499 IGNORED_C("asis-wrap-char", makeFalse());
1501 IGNORED_C("first-line-align", makeFalse());
1503 IGNORED_C("hyphenation-exceptions", makeNil());
1505 IGNORED_C("box-corner-rounded", makeFalse());
1506 IGNORED_C("table-corner-rounded", makeFalse());
1508 IGNORED_C("line-dash", new (*this) PairObj(length0, makeNil()));
1509 // list of glyphs/chars
1510 IGNORED_C("allowed-ligatures", makeNil());
1512 IGNORED_C("line-number", makeFalse());
1513 // integer or 'force
1514 IGNORED_C("line-spacing-priority", makeInteger(0));
1516 IGNORED_C("char-map", makeFalse());
1519 void Interpreter::installInheritedC(const char *s, InheritedC *ic)
1521 StringC name(makeStringC(s));
1522 Identifier *ident = lookup(name);
1523 ic->setIdentifier(ident);
1524 ident->setInheritedC(ic);
1525 installInheritedCProc(ident);
1526 if (dsssl2() && name.size() && name[name.size() - 1] == '?') {
1527 name.resize(name.size() - 1);
1528 Identifier *ident2 = lookup(name);
1529 ASSERT(ident2->inheritedC().isNull());
1530 ident2->setInheritedC(ic);
1531 installInheritedCProc(ident2);
1535 void Interpreter::installExtensionInheritedC(Identifier *ident,
1536 const StringC &pubid,
1537 const Location &loc)
1539 ConstPtr<InheritedC> ic;
1540 if (pubid.size() != 0 && extensionTable_) {
1541 for (const FOTBuilder::Extension *ep = extensionTable_; ep->pubid; ep++) {
1542 if (pubid == ep->pubid) {
1544 ic = new ExtensionBoolInheritedC(ident, nInheritedC_++, ep->boolSetter);
1545 else if (ep->stringSetter)
1546 ic = new ExtensionStringInheritedC(ident, nInheritedC_++, ep->stringSetter);
1547 else if (ep->integerSetter)
1548 ic = new ExtensionIntegerInheritedC(ident, nInheritedC_++, ep->integerSetter);
1549 else if (ep->lengthSetter)
1550 ic = new ExtensionLengthInheritedC(ident, nInheritedC_++, ep->lengthSetter);
1556 // FIXME should call FOTBuilder with PublicId argument
1557 ic = new IgnoredC(ident, nInheritedC_++, makeFalse(), *this);
1558 ident->setInheritedC(ic, currentPartIndex(), loc);
1559 installInheritedCProc(ident);
1562 void Interpreter::installInheritedCProc(const Identifier *ident)
1564 const ConstPtr<InheritedC> &ic = ident->inheritedC();
1565 StringC tem(makeStringC("inherited-"));
1566 tem += ident->name();
1567 Identifier *inhIdent = lookup(tem);
1568 PrimitiveObj *prim = new (*this) InheritedCPrimitiveObj(ic);
1569 makePermanent(prim);
1570 prim->setIdentifier(inhIdent);
1571 inhIdent->setValue(prim);
1572 tem = makeStringC("actual-");
1573 tem += ident->name();
1574 Identifier *actIdent = lookup(tem);
1575 prim = new (*this) ActualCPrimitiveObj(ic);
1576 makePermanent(prim);
1577 prim->setIdentifier(actIdent);
1578 actIdent->setValue(prim);
1581 #ifdef DSSSL_NAMESPACE