| 1 |
// Copyright (c) 1996 James Clark |
| 2 |
// See the file copying.txt for copying permission. |
| 3 |
|
| 4 |
#include "stylelib.h" |
| 5 |
#include "Style.h" |
| 6 |
#include "VM.h" |
| 7 |
#include "Interpreter.h" |
| 8 |
#include "InterpreterMessages.h" |
| 9 |
#include <OpenSP/macros.h> |
| 10 |
|
| 11 |
#ifdef DSSSL_NAMESPACE |
| 12 |
namespace DSSSL_NAMESPACE { |
| 13 |
#endif |
| 14 |
|
| 15 |
InheritedC::InheritedC(const Identifier *ident, unsigned index) |
| 16 |
: ident_(ident), index_(index) |
| 17 |
{ |
| 18 |
} |
| 19 |
|
| 20 |
InheritedC::~InheritedC() |
| 21 |
{ |
| 22 |
} |
| 23 |
|
| 24 |
void InheritedC::invalidValue(const Location &loc, |
| 25 |
Interpreter &interp) const |
| 26 |
{ |
| 27 |
interp.invalidCharacteristicValue(identifier(), loc); |
| 28 |
} |
| 29 |
|
| 30 |
class BoolInheritedC : public InheritedC { |
| 31 |
public: |
| 32 |
BoolInheritedC(const Identifier *, unsigned index, bool); |
| 33 |
ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const; |
| 34 |
protected: |
| 35 |
bool value_; |
| 36 |
}; |
| 37 |
|
| 38 |
BoolInheritedC::BoolInheritedC(const Identifier *ident, unsigned index, bool value) |
| 39 |
: InheritedC(ident, index), value_(value) |
| 40 |
{ |
| 41 |
} |
| 42 |
|
| 43 |
ELObj *BoolInheritedC::value(VM &vm, const VarStyleObj *, Vector<size_t> &) const |
| 44 |
{ |
| 45 |
if (value_) |
| 46 |
return vm.interp->makeTrue(); |
| 47 |
else |
| 48 |
return vm.interp->makeFalse(); |
| 49 |
} |
| 50 |
|
| 51 |
class IntegerInheritedC : public InheritedC { |
| 52 |
public: |
| 53 |
IntegerInheritedC(const Identifier *, unsigned index, long); |
| 54 |
ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const; |
| 55 |
protected: |
| 56 |
long n_; |
| 57 |
}; |
| 58 |
|
| 59 |
IntegerInheritedC::IntegerInheritedC(const Identifier *ident, unsigned index, long n) |
| 60 |
: InheritedC(ident, index), n_(n) |
| 61 |
{ |
| 62 |
} |
| 63 |
|
| 64 |
ELObj *IntegerInheritedC::value(VM &vm, const VarStyleObj *, Vector<size_t> &) const |
| 65 |
{ |
| 66 |
return vm.interp->makeInteger(n_); |
| 67 |
} |
| 68 |
|
| 69 |
class LengthInheritedC : public InheritedC { |
| 70 |
public: |
| 71 |
LengthInheritedC(const Identifier *, unsigned index, FOTBuilder::Length); |
| 72 |
ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const; |
| 73 |
protected: |
| 74 |
FOTBuilder::Length size_; |
| 75 |
}; |
| 76 |
|
| 77 |
LengthInheritedC::LengthInheritedC(const Identifier *ident, unsigned index, FOTBuilder::Length size) |
| 78 |
: InheritedC(ident, index), size_(size) |
| 79 |
{ |
| 80 |
} |
| 81 |
|
| 82 |
ELObj *LengthInheritedC::value(VM &vm, const VarStyleObj *, Vector<size_t> &) const |
| 83 |
{ |
| 84 |
return new (*vm.interp) LengthObj(size_); |
| 85 |
} |
| 86 |
|
| 87 |
class SymbolInheritedC : public InheritedC { |
| 88 |
public: |
| 89 |
SymbolInheritedC(const Identifier *, unsigned index, FOTBuilder::Symbol); |
| 90 |
ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const; |
| 91 |
protected: |
| 92 |
FOTBuilder::Symbol sym_; |
| 93 |
}; |
| 94 |
|
| 95 |
SymbolInheritedC::SymbolInheritedC(const Identifier *ident, unsigned index, FOTBuilder::Symbol sym) |
| 96 |
: InheritedC(ident, index), sym_(sym) |
| 97 |
{ |
| 98 |
} |
| 99 |
|
| 100 |
ELObj *SymbolInheritedC::value(VM &vm, const VarStyleObj *, Vector<size_t> &) const |
| 101 |
{ |
| 102 |
return vm.interp->cValueSymbol(sym_); |
| 103 |
} |
| 104 |
|
| 105 |
class PublicIdInheritedC : public InheritedC { |
| 106 |
public: |
| 107 |
PublicIdInheritedC(const Identifier *, unsigned index, |
| 108 |
FOTBuilder::PublicId = 0); |
| 109 |
ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const; |
| 110 |
protected: |
| 111 |
FOTBuilder::PublicId pubid_; |
| 112 |
}; |
| 113 |
|
| 114 |
PublicIdInheritedC::PublicIdInheritedC(const Identifier *ident, unsigned index, FOTBuilder::PublicId pubid) |
| 115 |
: InheritedC(ident, index), pubid_(pubid) |
| 116 |
{ |
| 117 |
} |
| 118 |
|
| 119 |
ELObj *PublicIdInheritedC::value(VM &vm, const VarStyleObj *, Vector<size_t> &) const |
| 120 |
{ |
| 121 |
Interpreter &interp = *vm.interp; |
| 122 |
if (pubid_) |
| 123 |
return new (interp) StringObj(interp.makeStringC(pubid_)); |
| 124 |
else |
| 125 |
return interp.makeFalse(); |
| 126 |
} |
| 127 |
|
| 128 |
class Letter2InheritedC : public InheritedC { |
| 129 |
public: |
| 130 |
Letter2InheritedC(const Identifier *, unsigned index, |
| 131 |
FOTBuilder::Letter2 = 0); |
| 132 |
ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const; |
| 133 |
protected: |
| 134 |
FOTBuilder::Letter2 code_; |
| 135 |
}; |
| 136 |
|
| 137 |
Letter2InheritedC::Letter2InheritedC(const Identifier *ident, unsigned index, |
| 138 |
FOTBuilder::Letter2 code) |
| 139 |
: InheritedC(ident, index), code_(code) |
| 140 |
{ |
| 141 |
} |
| 142 |
|
| 143 |
ELObj *Letter2InheritedC::value(VM &vm, const VarStyleObj *, Vector<size_t> &) const |
| 144 |
{ |
| 145 |
Interpreter &interp = *vm.interp; |
| 146 |
if (code_) { |
| 147 |
StringC buf; |
| 148 |
buf += (code_ >> 8) & 0xff; |
| 149 |
buf += code_ & 0xff; |
| 150 |
buf += 0; |
| 151 |
return interp.makeSymbol(buf); |
| 152 |
} |
| 153 |
else |
| 154 |
return interp.makeFalse(); |
| 155 |
} |
| 156 |
|
| 157 |
class LengthSpecInheritedC : public InheritedC { |
| 158 |
public: |
| 159 |
LengthSpecInheritedC(const Identifier *, unsigned index, FOTBuilder::Length); |
| 160 |
ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const; |
| 161 |
protected: |
| 162 |
bool setValue(ELObj *, const Location &, Interpreter &); |
| 163 |
FOTBuilder::LengthSpec value_; |
| 164 |
}; |
| 165 |
|
| 166 |
|
| 167 |
LengthSpecInheritedC::LengthSpecInheritedC(const Identifier *ident, |
| 168 |
unsigned index, FOTBuilder::Length n) |
| 169 |
: InheritedC(ident, index), value_(n) |
| 170 |
{ |
| 171 |
} |
| 172 |
|
| 173 |
ELObj *LengthSpecInheritedC::value(VM &vm, const VarStyleObj *, |
| 174 |
Vector<size_t> &) const |
| 175 |
{ |
| 176 |
return vm.interp->makeLengthSpec(value_); |
| 177 |
} |
| 178 |
|
| 179 |
bool LengthSpecInheritedC::setValue(ELObj *obj, const Location &loc, |
| 180 |
Interpreter &interp) |
| 181 |
{ |
| 182 |
return interp.convertLengthSpecC(obj, identifier(), loc, value_); |
| 183 |
} |
| 184 |
|
| 185 |
class OptLengthSpecInheritedC : public InheritedC { |
| 186 |
public: |
| 187 |
OptLengthSpecInheritedC(const Identifier *, unsigned index); |
| 188 |
ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const; |
| 189 |
protected: |
| 190 |
bool setValue(ELObj *, const Location &, Interpreter &); |
| 191 |
FOTBuilder::OptLengthSpec value_; |
| 192 |
}; |
| 193 |
|
| 194 |
|
| 195 |
OptLengthSpecInheritedC::OptLengthSpecInheritedC(const Identifier *ident, |
| 196 |
unsigned index) |
| 197 |
: InheritedC(ident, index) |
| 198 |
{ |
| 199 |
} |
| 200 |
|
| 201 |
ELObj *OptLengthSpecInheritedC::value(VM &vm, const VarStyleObj *, |
| 202 |
Vector<size_t> &) const |
| 203 |
{ |
| 204 |
if (!value_.hasLength) |
| 205 |
return vm.interp->makeFalse(); |
| 206 |
else |
| 207 |
return vm.interp->makeLengthSpec(value_.length); |
| 208 |
} |
| 209 |
|
| 210 |
bool OptLengthSpecInheritedC::setValue(ELObj *obj, const Location &loc, |
| 211 |
Interpreter &interp) |
| 212 |
{ |
| 213 |
return interp.convertOptLengthSpecC(obj, identifier(), loc, value_); |
| 214 |
} |
| 215 |
|
| 216 |
class StringInheritedC : public InheritedC { |
| 217 |
public: |
| 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; |
| 221 |
protected: |
| 222 |
StringC str_; |
| 223 |
}; |
| 224 |
|
| 225 |
StringInheritedC::StringInheritedC(const Identifier *ident, unsigned index, |
| 226 |
const Char *s, size_t n) |
| 227 |
: InheritedC(ident, index), str_(s, n) |
| 228 |
{ |
| 229 |
} |
| 230 |
|
| 231 |
StringInheritedC::StringInheritedC(const Identifier *ident, unsigned index, |
| 232 |
const StringC &s) |
| 233 |
: InheritedC(ident, index), str_(s) |
| 234 |
{ |
| 235 |
} |
| 236 |
|
| 237 |
ELObj *StringInheritedC::value(VM &vm, const VarStyleObj *, Vector<size_t> &) const |
| 238 |
{ |
| 239 |
return new(*vm.interp) StringObj(str_); |
| 240 |
} |
| 241 |
|
| 242 |
class GenericInlineSpaceInheritedC : public InheritedC { |
| 243 |
public: |
| 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; |
| 250 |
private: |
| 251 |
FOTBuilder::InlineSpace value_; |
| 252 |
Setter setter_; |
| 253 |
}; |
| 254 |
|
| 255 |
GenericInlineSpaceInheritedC::GenericInlineSpaceInheritedC(const Identifier *ident, |
| 256 |
unsigned index, |
| 257 |
Setter setter) |
| 258 |
: InheritedC(ident, index), setter_(setter) |
| 259 |
{ |
| 260 |
} |
| 261 |
|
| 262 |
ELObj *GenericInlineSpaceInheritedC::value(VM &vm, const VarStyleObj *, |
| 263 |
Vector<size_t> &) const |
| 264 |
{ |
| 265 |
return new (*vm.interp) InlineSpaceObj(value_); |
| 266 |
} |
| 267 |
|
| 268 |
void GenericInlineSpaceInheritedC::set(VM &, const VarStyleObj *, |
| 269 |
FOTBuilder &fotb, |
| 270 |
ELObj *&, |
| 271 |
Vector<size_t> &) const |
| 272 |
{ |
| 273 |
(fotb.*setter_)(value_); |
| 274 |
} |
| 275 |
|
| 276 |
ConstPtr<InheritedC> |
| 277 |
GenericInlineSpaceInheritedC::make(ELObj *obj, const Location &loc, |
| 278 |
Interpreter &interp) const |
| 279 |
{ |
| 280 |
GenericInlineSpaceInheritedC *copy |
| 281 |
= new GenericInlineSpaceInheritedC(identifier(), index(), setter_); |
| 282 |
InlineSpaceObj *iso = obj->asInlineSpace(); |
| 283 |
if (iso) { |
| 284 |
copy->value_ = iso->inlineSpace(); |
| 285 |
return copy; |
| 286 |
} |
| 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; |
| 290 |
return copy; |
| 291 |
} |
| 292 |
delete copy; |
| 293 |
return 0; |
| 294 |
} |
| 295 |
|
| 296 |
|
| 297 |
class GenericBoolInheritedC : public BoolInheritedC { |
| 298 |
public: |
| 299 |
typedef void (FOTBuilder::*Setter)(bool); |
| 300 |
GenericBoolInheritedC(const Identifier *, unsigned index, Setter, |
| 301 |
bool = 0); |
| 302 |
void set(VM &, const VarStyleObj *, FOTBuilder &, |
| 303 |
ELObj *&value, Vector<size_t> &dependencies) const; |
| 304 |
ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const; |
| 305 |
private: |
| 306 |
Setter setter_; |
| 307 |
}; |
| 308 |
|
| 309 |
GenericBoolInheritedC |
| 310 |
::GenericBoolInheritedC(const Identifier *ident, unsigned index, |
| 311 |
Setter setter, bool b) |
| 312 |
: BoolInheritedC(ident, index, b), setter_(setter) |
| 313 |
{ |
| 314 |
} |
| 315 |
|
| 316 |
void GenericBoolInheritedC::set(VM &, const VarStyleObj *, |
| 317 |
FOTBuilder &fotb, |
| 318 |
ELObj *&, |
| 319 |
Vector<size_t> &) const |
| 320 |
{ |
| 321 |
(fotb.*setter_)(value_); |
| 322 |
} |
| 323 |
|
| 324 |
ConstPtr<InheritedC> |
| 325 |
GenericBoolInheritedC::make(ELObj *obj, const Location &loc, |
| 326 |
Interpreter &interp) const |
| 327 |
{ |
| 328 |
bool b; |
| 329 |
if (interp.convertBooleanC(obj, identifier(), loc, b)) |
| 330 |
return new GenericBoolInheritedC(identifier(), index(), setter_, b); |
| 331 |
return ConstPtr<InheritedC>(); |
| 332 |
} |
| 333 |
|
| 334 |
class ExtensionBoolInheritedC : public BoolInheritedC { |
| 335 |
public: |
| 336 |
typedef void (FOTBuilder::*Setter)(bool); |
| 337 |
ExtensionBoolInheritedC(const Identifier *, unsigned index, Setter, |
| 338 |
bool = 0); |
| 339 |
void set(VM &, const VarStyleObj *, FOTBuilder &, |
| 340 |
ELObj *&value, Vector<size_t> &dependencies) const; |
| 341 |
ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const; |
| 342 |
private: |
| 343 |
Setter setter_; |
| 344 |
}; |
| 345 |
|
| 346 |
ExtensionBoolInheritedC |
| 347 |
::ExtensionBoolInheritedC(const Identifier *ident, unsigned index, |
| 348 |
Setter setter, bool b) |
| 349 |
: BoolInheritedC(ident, index, b), setter_(setter) |
| 350 |
{ |
| 351 |
} |
| 352 |
|
| 353 |
void ExtensionBoolInheritedC::set(VM &, const VarStyleObj *, |
| 354 |
FOTBuilder &fotb, |
| 355 |
ELObj *&, |
| 356 |
Vector<size_t> &) const |
| 357 |
{ |
| 358 |
fotb.extensionSet(setter_, value_); |
| 359 |
} |
| 360 |
|
| 361 |
ConstPtr<InheritedC> |
| 362 |
ExtensionBoolInheritedC::make(ELObj *obj, const Location &loc, |
| 363 |
Interpreter &interp) const |
| 364 |
{ |
| 365 |
bool b; |
| 366 |
if (interp.convertBooleanC(obj, identifier(), loc, b)) |
| 367 |
return new ExtensionBoolInheritedC(identifier(), index(), setter_, b); |
| 368 |
return ConstPtr<InheritedC>(); |
| 369 |
} |
| 370 |
|
| 371 |
class ExtensionStringInheritedC : public StringInheritedC { |
| 372 |
public: |
| 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; |
| 380 |
private: |
| 381 |
Setter setter_; |
| 382 |
}; |
| 383 |
|
| 384 |
ExtensionStringInheritedC |
| 385 |
::ExtensionStringInheritedC(const Identifier *ident, unsigned index, |
| 386 |
Setter setter) |
| 387 |
: StringInheritedC(ident, index, StringC()), setter_(setter) |
| 388 |
{ |
| 389 |
} |
| 390 |
|
| 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) |
| 395 |
{ |
| 396 |
} |
| 397 |
|
| 398 |
void ExtensionStringInheritedC::set(VM &, const VarStyleObj *, |
| 399 |
FOTBuilder &fotb, |
| 400 |
ELObj *&, |
| 401 |
Vector<size_t> &) const |
| 402 |
{ |
| 403 |
fotb.extensionSet(setter_, str_); |
| 404 |
} |
| 405 |
|
| 406 |
ConstPtr<InheritedC> |
| 407 |
ExtensionStringInheritedC::make(ELObj *obj, const Location &loc, |
| 408 |
Interpreter &interp) const |
| 409 |
{ |
| 410 |
const Char *s; |
| 411 |
size_t n; |
| 412 |
if (obj->stringData(s, n)) |
| 413 |
return new ExtensionStringInheritedC(identifier(), index(), setter_, s, n); |
| 414 |
invalidValue(loc, interp); |
| 415 |
return ConstPtr<InheritedC>(); |
| 416 |
} |
| 417 |
|
| 418 |
class ExtensionIntegerInheritedC : public IntegerInheritedC { |
| 419 |
public: |
| 420 |
typedef void (FOTBuilder::*Setter)(long); |
| 421 |
ExtensionIntegerInheritedC(const Identifier *, unsigned index, Setter, |
| 422 |
long = 0); |
| 423 |
void set(VM &, const VarStyleObj *, FOTBuilder &, |
| 424 |
ELObj *&value, Vector<size_t> &dependencies) const; |
| 425 |
ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const; |
| 426 |
private: |
| 427 |
Setter setter_; |
| 428 |
}; |
| 429 |
|
| 430 |
ExtensionIntegerInheritedC |
| 431 |
::ExtensionIntegerInheritedC(const Identifier *ident, unsigned index, |
| 432 |
Setter setter, long n) |
| 433 |
: IntegerInheritedC(ident, index, n), setter_(setter) |
| 434 |
{ |
| 435 |
} |
| 436 |
|
| 437 |
void ExtensionIntegerInheritedC::set(VM &, const VarStyleObj *, |
| 438 |
FOTBuilder &fotb, |
| 439 |
ELObj *&, |
| 440 |
Vector<size_t> &) const |
| 441 |
{ |
| 442 |
fotb.extensionSet(setter_, n_); |
| 443 |
} |
| 444 |
|
| 445 |
ConstPtr<InheritedC> |
| 446 |
ExtensionIntegerInheritedC::make(ELObj *obj, const Location &loc, |
| 447 |
Interpreter &interp) const |
| 448 |
{ |
| 449 |
long n; |
| 450 |
if (interp.convertIntegerC(obj, identifier(), loc, n)) |
| 451 |
return new ExtensionIntegerInheritedC(identifier(), index(), setter_, n); |
| 452 |
return ConstPtr<InheritedC>(); |
| 453 |
} |
| 454 |
|
| 455 |
class ExtensionLengthInheritedC : public LengthInheritedC { |
| 456 |
public: |
| 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; |
| 462 |
private: |
| 463 |
Setter setter_; |
| 464 |
}; |
| 465 |
|
| 466 |
ExtensionLengthInheritedC |
| 467 |
::ExtensionLengthInheritedC(const Identifier *ident, unsigned index, |
| 468 |
Setter setter, FOTBuilder::Length n) |
| 469 |
: LengthInheritedC(ident, index, n), setter_(setter) |
| 470 |
{ |
| 471 |
} |
| 472 |
|
| 473 |
void ExtensionLengthInheritedC::set(VM &, const VarStyleObj *, |
| 474 |
FOTBuilder &fotb, |
| 475 |
ELObj *&, |
| 476 |
Vector<size_t> &) const |
| 477 |
{ |
| 478 |
fotb.extensionSet(setter_, size_); |
| 479 |
} |
| 480 |
|
| 481 |
ConstPtr<InheritedC> |
| 482 |
ExtensionLengthInheritedC::make(ELObj *obj, const Location &loc, |
| 483 |
Interpreter &interp) const |
| 484 |
{ |
| 485 |
FOTBuilder::Length n; |
| 486 |
if (interp.convertLengthC(obj, identifier(), loc, n)) |
| 487 |
return new ExtensionLengthInheritedC(identifier(), index(), setter_, n); |
| 488 |
return ConstPtr<InheritedC>(); |
| 489 |
} |
| 490 |
|
| 491 |
class GenericLengthInheritedC : public LengthInheritedC { |
| 492 |
public: |
| 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; |
| 499 |
private: |
| 500 |
Setter setter_; |
| 501 |
}; |
| 502 |
|
| 503 |
GenericLengthInheritedC |
| 504 |
::GenericLengthInheritedC(const Identifier *ident, unsigned index, |
| 505 |
Setter setter, FOTBuilder::Length n) |
| 506 |
: LengthInheritedC(ident, index, n), setter_(setter) |
| 507 |
{ |
| 508 |
} |
| 509 |
|
| 510 |
void GenericLengthInheritedC::set(VM &, const VarStyleObj *, |
| 511 |
FOTBuilder &fotb, |
| 512 |
ELObj *&, |
| 513 |
Vector<size_t> &) const |
| 514 |
{ |
| 515 |
(fotb.*setter_)(size_); |
| 516 |
} |
| 517 |
|
| 518 |
ConstPtr<InheritedC> |
| 519 |
GenericLengthInheritedC::make(ELObj *obj, const Location &loc, |
| 520 |
Interpreter &interp) const |
| 521 |
{ |
| 522 |
FOTBuilder::Length n; |
| 523 |
if (interp.convertLengthC(obj, identifier(), loc, n)) |
| 524 |
return new GenericLengthInheritedC(identifier(), index(), setter_, n); |
| 525 |
return ConstPtr<InheritedC>(); |
| 526 |
} |
| 527 |
|
| 528 |
class GenericIntegerInheritedC : public IntegerInheritedC { |
| 529 |
public: |
| 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; |
| 535 |
protected: |
| 536 |
Setter setter_; |
| 537 |
}; |
| 538 |
|
| 539 |
GenericIntegerInheritedC |
| 540 |
::GenericIntegerInheritedC(const Identifier *ident, unsigned index, |
| 541 |
Setter setter, long n) |
| 542 |
: IntegerInheritedC(ident, index, n), setter_(setter) |
| 543 |
{ |
| 544 |
} |
| 545 |
|
| 546 |
void GenericIntegerInheritedC::set(VM &, const VarStyleObj *, |
| 547 |
FOTBuilder &fotb, |
| 548 |
ELObj *&, |
| 549 |
Vector<size_t> &) const |
| 550 |
{ |
| 551 |
(fotb.*setter_)(n_); |
| 552 |
} |
| 553 |
|
| 554 |
ConstPtr<InheritedC> |
| 555 |
GenericIntegerInheritedC::make(ELObj *obj, const Location &loc, |
| 556 |
Interpreter &interp) const |
| 557 |
{ |
| 558 |
long n; |
| 559 |
if (interp.convertIntegerC(obj, identifier(), loc, n)) |
| 560 |
return new GenericIntegerInheritedC(identifier(), index(), setter_, n); |
| 561 |
return ConstPtr<InheritedC>(); |
| 562 |
} |
| 563 |
|
| 564 |
class GenericMaybeIntegerInheritedC : public GenericIntegerInheritedC { |
| 565 |
public: |
| 566 |
GenericMaybeIntegerInheritedC(const Identifier *, unsigned index, |
| 567 |
Setter, long); |
| 568 |
ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const; |
| 569 |
ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const; |
| 570 |
}; |
| 571 |
|
| 572 |
GenericMaybeIntegerInheritedC |
| 573 |
::GenericMaybeIntegerInheritedC(const Identifier *ident, unsigned index, |
| 574 |
Setter setter, long n) |
| 575 |
: GenericIntegerInheritedC(ident, index, setter, n) |
| 576 |
{ |
| 577 |
} |
| 578 |
|
| 579 |
ELObj *GenericMaybeIntegerInheritedC::value(VM &vm, const VarStyleObj *style, |
| 580 |
Vector<size_t> &dep) const |
| 581 |
{ |
| 582 |
if (!n_) |
| 583 |
return vm.interp->makeFalse(); |
| 584 |
else |
| 585 |
return IntegerInheritedC::value(vm, style, dep); |
| 586 |
} |
| 587 |
|
| 588 |
ConstPtr<InheritedC> |
| 589 |
GenericMaybeIntegerInheritedC::make(ELObj *obj, const Location &loc, |
| 590 |
Interpreter &interp) const |
| 591 |
{ |
| 592 |
long n; |
| 593 |
if (interp.convertOptPositiveIntegerC(obj, identifier(), loc, n)) |
| 594 |
return new GenericMaybeIntegerInheritedC(identifier(), index(), |
| 595 |
setter_, n); |
| 596 |
return ConstPtr<InheritedC>(); |
| 597 |
} |
| 598 |
|
| 599 |
class GenericSymbolInheritedC : public SymbolInheritedC { |
| 600 |
public: |
| 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; |
| 607 |
private: |
| 608 |
Setter setter_; |
| 609 |
}; |
| 610 |
|
| 611 |
GenericSymbolInheritedC |
| 612 |
::GenericSymbolInheritedC(const Identifier *ident, unsigned index, |
| 613 |
Setter setter, FOTBuilder::Symbol sym) |
| 614 |
: SymbolInheritedC(ident, index, sym), setter_(setter) |
| 615 |
{ |
| 616 |
} |
| 617 |
|
| 618 |
void GenericSymbolInheritedC::set(VM &, const VarStyleObj *, |
| 619 |
FOTBuilder &fotb, |
| 620 |
ELObj *&, |
| 621 |
Vector<size_t> &) const |
| 622 |
{ |
| 623 |
(fotb.*setter_)(sym_); |
| 624 |
} |
| 625 |
|
| 626 |
ConstPtr<InheritedC> |
| 627 |
GenericSymbolInheritedC::make(ELObj *obj, const Location &loc, |
| 628 |
Interpreter &interp) const |
| 629 |
{ |
| 630 |
FOTBuilder::Symbol sym; |
| 631 |
if (interp.convertEnumC(obj, identifier(), loc, sym)) |
| 632 |
return new GenericSymbolInheritedC(identifier(), index(), setter_, sym); |
| 633 |
return ConstPtr<InheritedC>(); |
| 634 |
} |
| 635 |
|
| 636 |
class GenericPublicIdInheritedC : public PublicIdInheritedC { |
| 637 |
public: |
| 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; |
| 644 |
private: |
| 645 |
Setter setter_; |
| 646 |
}; |
| 647 |
|
| 648 |
GenericPublicIdInheritedC |
| 649 |
::GenericPublicIdInheritedC(const Identifier *ident, unsigned index, |
| 650 |
Setter setter, FOTBuilder::PublicId pubid) |
| 651 |
: PublicIdInheritedC(ident, index, pubid), setter_(setter) |
| 652 |
{ |
| 653 |
} |
| 654 |
|
| 655 |
void GenericPublicIdInheritedC::set(VM &, const VarStyleObj *, |
| 656 |
FOTBuilder &fotb, |
| 657 |
ELObj *&, |
| 658 |
Vector<size_t> &) const |
| 659 |
{ |
| 660 |
(fotb.*setter_)(pubid_); |
| 661 |
} |
| 662 |
|
| 663 |
ConstPtr<InheritedC> |
| 664 |
GenericPublicIdInheritedC::make(ELObj *obj, const Location &loc, |
| 665 |
Interpreter &interp) const |
| 666 |
{ |
| 667 |
FOTBuilder::PublicId pubid; |
| 668 |
if (interp.convertPublicIdC(obj, identifier(), loc, pubid)) |
| 669 |
return new GenericPublicIdInheritedC(identifier(), index(), setter_, |
| 670 |
pubid); |
| 671 |
return ConstPtr<InheritedC>(); |
| 672 |
} |
| 673 |
|
| 674 |
class GenericLetter2InheritedC : public Letter2InheritedC { |
| 675 |
public: |
| 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; |
| 682 |
private: |
| 683 |
Setter setter_; |
| 684 |
}; |
| 685 |
|
| 686 |
GenericLetter2InheritedC |
| 687 |
::GenericLetter2InheritedC(const Identifier *ident, unsigned index, |
| 688 |
Setter setter, FOTBuilder::Letter2 code) |
| 689 |
: Letter2InheritedC(ident, index, code), setter_(setter) |
| 690 |
{ |
| 691 |
} |
| 692 |
|
| 693 |
void GenericLetter2InheritedC::set(VM &, const VarStyleObj *, |
| 694 |
FOTBuilder &fotb, |
| 695 |
ELObj *&, |
| 696 |
Vector<size_t> &) const |
| 697 |
{ |
| 698 |
(fotb.*setter_)(code_); |
| 699 |
} |
| 700 |
|
| 701 |
ConstPtr<InheritedC> |
| 702 |
GenericLetter2InheritedC::make(ELObj *obj, const Location &loc, |
| 703 |
Interpreter &interp) const |
| 704 |
{ |
| 705 |
FOTBuilder::Letter2 code; |
| 706 |
if (interp.convertLetter2C(obj, identifier(), loc, code)) |
| 707 |
return new GenericLetter2InheritedC(identifier(), index(), setter_, code); |
| 708 |
return ConstPtr<InheritedC>(); |
| 709 |
} |
| 710 |
|
| 711 |
class GenericLengthSpecInheritedC : public LengthSpecInheritedC { |
| 712 |
public: |
| 713 |
typedef void (FOTBuilder::*Setter)(const FOTBuilder::LengthSpec &); |
| 714 |
GenericLengthSpecInheritedC(const Identifier *, unsigned index, Setter, |
| 715 |
long = 0); |
| 716 |
void set(VM &, const VarStyleObj *, FOTBuilder &, |
| 717 |
ELObj *&value, Vector<size_t> &dependencies) const; |
| 718 |
ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const; |
| 719 |
private: |
| 720 |
Setter setter_; |
| 721 |
}; |
| 722 |
|
| 723 |
GenericLengthSpecInheritedC |
| 724 |
::GenericLengthSpecInheritedC(const Identifier *ident, unsigned index, |
| 725 |
Setter setter, long n) |
| 726 |
: LengthSpecInheritedC(ident, index, n), setter_(setter) |
| 727 |
{ |
| 728 |
} |
| 729 |
|
| 730 |
void GenericLengthSpecInheritedC::set(VM &, const VarStyleObj *, |
| 731 |
FOTBuilder &fotb, |
| 732 |
ELObj *&, |
| 733 |
Vector<size_t> &) const |
| 734 |
{ |
| 735 |
(fotb.*setter_)(value_); |
| 736 |
} |
| 737 |
|
| 738 |
ConstPtr<InheritedC> |
| 739 |
GenericLengthSpecInheritedC::make(ELObj *obj, const Location &loc, |
| 740 |
Interpreter &interp) const |
| 741 |
{ |
| 742 |
GenericLengthSpecInheritedC *copy |
| 743 |
= new GenericLengthSpecInheritedC(identifier(), index(), setter_); |
| 744 |
if (!copy->setValue(obj, loc, interp)) { |
| 745 |
delete copy; |
| 746 |
copy = 0; |
| 747 |
} |
| 748 |
return copy; |
| 749 |
} |
| 750 |
|
| 751 |
class GenericOptInlineSpaceInheritedC : public InheritedC { |
| 752 |
public: |
| 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; |
| 759 |
private: |
| 760 |
FOTBuilder::OptInlineSpace value_; |
| 761 |
Setter setter_; |
| 762 |
}; |
| 763 |
|
| 764 |
GenericOptInlineSpaceInheritedC |
| 765 |
::GenericOptInlineSpaceInheritedC(const Identifier *ident, unsigned index, |
| 766 |
Setter setter) |
| 767 |
: InheritedC(ident, index), setter_(setter) |
| 768 |
{ |
| 769 |
} |
| 770 |
|
| 771 |
ELObj *GenericOptInlineSpaceInheritedC::value(VM &vm, const VarStyleObj *, |
| 772 |
Vector<size_t> &) const |
| 773 |
{ |
| 774 |
if (!value_.hasSpace) |
| 775 |
return vm.interp->makeFalse(); |
| 776 |
else |
| 777 |
return new (*vm.interp) InlineSpaceObj(value_.space); |
| 778 |
} |
| 779 |
|
| 780 |
|
| 781 |
void GenericOptInlineSpaceInheritedC::set(VM &, const VarStyleObj *, |
| 782 |
FOTBuilder &fotb, |
| 783 |
ELObj *&, |
| 784 |
Vector<size_t> &) const |
| 785 |
{ |
| 786 |
(fotb.*setter_)(value_); |
| 787 |
} |
| 788 |
|
| 789 |
ConstPtr<InheritedC> |
| 790 |
GenericOptInlineSpaceInheritedC::make(ELObj *obj, const Location &loc, |
| 791 |
Interpreter &interp) const |
| 792 |
{ |
| 793 |
GenericOptInlineSpaceInheritedC *copy |
| 794 |
= new GenericOptInlineSpaceInheritedC(identifier(), index(), setter_); |
| 795 |
InlineSpaceObj *iso = obj->asInlineSpace(); |
| 796 |
if (iso) { |
| 797 |
copy->value_.space = iso->inlineSpace(); |
| 798 |
copy->value_.hasSpace = 1; |
| 799 |
} |
| 800 |
else { |
| 801 |
FOTBuilder::OptLengthSpec res; |
| 802 |
if (interp.convertOptLengthSpecC(obj, identifier(), loc, res)) { |
| 803 |
if (res.hasLength) { |
| 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; |
| 808 |
} else |
| 809 |
copy->value_.hasSpace = 0; |
| 810 |
} else { |
| 811 |
delete copy; |
| 812 |
copy = 0; |
| 813 |
} |
| 814 |
} |
| 815 |
return copy; |
| 816 |
} |
| 817 |
|
| 818 |
|
| 819 |
class GenericOptLengthSpecInheritedC : public OptLengthSpecInheritedC { |
| 820 |
public: |
| 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; |
| 826 |
private: |
| 827 |
Setter setter_; |
| 828 |
}; |
| 829 |
|
| 830 |
GenericOptLengthSpecInheritedC |
| 831 |
::GenericOptLengthSpecInheritedC(const Identifier *ident, unsigned index, |
| 832 |
Setter setter) |
| 833 |
: OptLengthSpecInheritedC(ident, index), setter_(setter) |
| 834 |
{ |
| 835 |
} |
| 836 |
|
| 837 |
void GenericOptLengthSpecInheritedC::set(VM &, const VarStyleObj *, |
| 838 |
FOTBuilder &fotb, |
| 839 |
ELObj *&, |
| 840 |
Vector<size_t> &) const |
| 841 |
{ |
| 842 |
(fotb.*setter_)(value_); |
| 843 |
} |
| 844 |
|
| 845 |
ConstPtr<InheritedC> |
| 846 |
GenericOptLengthSpecInheritedC::make(ELObj *obj, const Location &loc, |
| 847 |
Interpreter &interp) const |
| 848 |
{ |
| 849 |
GenericOptLengthSpecInheritedC *copy |
| 850 |
= new GenericOptLengthSpecInheritedC(identifier(), index(), setter_); |
| 851 |
if (!copy->setValue(obj, loc, interp)) { |
| 852 |
delete copy; |
| 853 |
copy = 0; |
| 854 |
} |
| 855 |
return copy; |
| 856 |
} |
| 857 |
|
| 858 |
class FontSizeC : public LengthInheritedC { |
| 859 |
public: |
| 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; |
| 864 |
}; |
| 865 |
|
| 866 |
FontSizeC::FontSizeC(const Identifier *ident, unsigned index, long size) |
| 867 |
: LengthInheritedC(ident, index, size) |
| 868 |
{ |
| 869 |
} |
| 870 |
|
| 871 |
void FontSizeC::set(VM &vm, const VarStyleObj *, FOTBuilder &fotb, ELObj *&, |
| 872 |
Vector<size_t> &) const |
| 873 |
{ |
| 874 |
fotb.setFontSize(size_); |
| 875 |
} |
| 876 |
|
| 877 |
ConstPtr<InheritedC> FontSizeC::make(ELObj *obj, const Location &loc, |
| 878 |
Interpreter &interp) const |
| 879 |
{ |
| 880 |
long n; |
| 881 |
if (interp.convertLengthC(obj, identifier(), loc, n)) |
| 882 |
return new FontSizeC(identifier(), index(), n); |
| 883 |
return ConstPtr<InheritedC>(); |
| 884 |
} |
| 885 |
|
| 886 |
class FontFamilyNameC : public StringInheritedC { |
| 887 |
public: |
| 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; |
| 893 |
}; |
| 894 |
|
| 895 |
FontFamilyNameC::FontFamilyNameC(const Identifier *ident, unsigned index, const Char *s, size_t n) |
| 896 |
: StringInheritedC(ident, index, s, n) |
| 897 |
{ |
| 898 |
} |
| 899 |
|
| 900 |
FontFamilyNameC::FontFamilyNameC(const Identifier *ident, unsigned index, const StringC &s) |
| 901 |
: StringInheritedC(ident, index, s) |
| 902 |
{ |
| 903 |
} |
| 904 |
|
| 905 |
void FontFamilyNameC::set(VM &vm, const VarStyleObj *, FOTBuilder &fotb, ELObj *&, |
| 906 |
Vector<size_t> &) const |
| 907 |
{ |
| 908 |
fotb.setFontFamilyName(str_); |
| 909 |
} |
| 910 |
|
| 911 |
ConstPtr<InheritedC> FontFamilyNameC::make(ELObj *obj, const Location &loc, |
| 912 |
Interpreter &interp) const |
| 913 |
{ |
| 914 |
const Char *s; |
| 915 |
size_t n; |
| 916 |
if (obj->stringData(s, n)) |
| 917 |
return new FontFamilyNameC(identifier(), index(), s, n); |
| 918 |
invalidValue(loc, interp); |
| 919 |
return ConstPtr<InheritedC>(); |
| 920 |
} |
| 921 |
|
| 922 |
class ColorC : public InheritedC, private Collector::DynamicRoot { |
| 923 |
public: |
| 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; |
| 930 |
private: |
| 931 |
ColorObj *color_; |
| 932 |
}; |
| 933 |
|
| 934 |
ColorC::ColorC(const Identifier *ident, unsigned index, ColorObj *color, |
| 935 |
Interpreter &interp) |
| 936 |
: InheritedC(ident, index), Collector::DynamicRoot(interp), color_(color) |
| 937 |
{ |
| 938 |
} |
| 939 |
|
| 940 |
void ColorC::set(VM &, const VarStyleObj *, FOTBuilder &fotb, |
| 941 |
ELObj *&, Vector<size_t> &) const |
| 942 |
{ |
| 943 |
color_->set(fotb); |
| 944 |
} |
| 945 |
|
| 946 |
ConstPtr<InheritedC> ColorC::make(ELObj *obj, const Location &loc, |
| 947 |
Interpreter &interp) const |
| 948 |
{ |
| 949 |
ColorObj *color; |
| 950 |
if (interp.convertColorC(obj, identifier(), loc, color)) |
| 951 |
return new ColorC(identifier(), index(), color, interp); |
| 952 |
return ConstPtr<InheritedC>(); |
| 953 |
} |
| 954 |
|
| 955 |
ELObj *ColorC::value(VM &vm, const VarStyleObj *, Vector<size_t> &) const |
| 956 |
{ |
| 957 |
if (!color_) |
| 958 |
return vm.interp->makeFalse(); |
| 959 |
else |
| 960 |
return color_; |
| 961 |
} |
| 962 |
|
| 963 |
void ColorC::trace(Collector &c) const |
| 964 |
{ |
| 965 |
c.trace(color_); |
| 966 |
} |
| 967 |
|
| 968 |
class BackgroundColorC : public InheritedC, private Collector::DynamicRoot { |
| 969 |
public: |
| 970 |
BackgroundColorC(const Identifier *, unsigned index, ColorObj *, |
| 971 |
Interpreter &); |
| 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; |
| 977 |
private: |
| 978 |
ColorObj *color_; |
| 979 |
}; |
| 980 |
|
| 981 |
BackgroundColorC::BackgroundColorC(const Identifier *ident, unsigned index, |
| 982 |
ColorObj *color, Interpreter &interp) |
| 983 |
: InheritedC(ident, index), Collector::DynamicRoot(interp), color_(color) |
| 984 |
{ |
| 985 |
} |
| 986 |
|
| 987 |
void BackgroundColorC::set(VM &, const VarStyleObj *, FOTBuilder &fotb, |
| 988 |
ELObj *&, Vector<size_t> &) const |
| 989 |
{ |
| 990 |
if (color_) |
| 991 |
color_->setBackground(fotb); |
| 992 |
else |
| 993 |
fotb.setBackgroundColor(); |
| 994 |
} |
| 995 |
|
| 996 |
ConstPtr<InheritedC> BackgroundColorC::make(ELObj *obj, const Location &loc, |
| 997 |
Interpreter &interp) const |
| 998 |
{ |
| 999 |
ColorObj *color; |
| 1000 |
if (interp.convertOptColorC(obj, identifier(), loc, color)) |
| 1001 |
return new BackgroundColorC(identifier(), index(), color, interp); |
| 1002 |
return ConstPtr<InheritedC>(); |
| 1003 |
} |
| 1004 |
|
| 1005 |
ELObj * |
| 1006 |
BackgroundColorC::value(VM &vm, const VarStyleObj *, Vector<size_t> &) const |
| 1007 |
{ |
| 1008 |
if (color_) |
| 1009 |
return color_; |
| 1010 |
else |
| 1011 |
return vm.interp->makeFalse(); |
| 1012 |
} |
| 1013 |
|
| 1014 |
void BackgroundColorC::trace(Collector &c) const |
| 1015 |
{ |
| 1016 |
c.trace(color_); |
| 1017 |
} |
| 1018 |
|
| 1019 |
class GlyphSubstTableC : public InheritedC { |
| 1020 |
public: |
| 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); } |
| 1027 |
private: |
| 1028 |
// Distinguish between #f and () for inherited-glyph-subst-table |
| 1029 |
bool isList_; |
| 1030 |
Vector<ConstPtr<FOTBuilder::GlyphSubstTable> > tables_; |
| 1031 |
}; |
| 1032 |
|
| 1033 |
GlyphSubstTableC::GlyphSubstTableC(const Identifier *ident, unsigned index, bool isList) |
| 1034 |
: InheritedC(ident, index), isList_(isList) |
| 1035 |
{ |
| 1036 |
} |
| 1037 |
|
| 1038 |
void GlyphSubstTableC::set(VM &, const VarStyleObj *, FOTBuilder &fotb, |
| 1039 |
ELObj *&, Vector<size_t> &) const |
| 1040 |
{ |
| 1041 |
fotb.setGlyphSubstTable(tables_); |
| 1042 |
} |
| 1043 |
|
| 1044 |
ConstPtr<InheritedC> GlyphSubstTableC::make(ELObj *obj, const Location &loc, |
| 1045 |
Interpreter &interp) const |
| 1046 |
{ |
| 1047 |
if (obj == interp.makeFalse()) |
| 1048 |
return new GlyphSubstTableC(identifier(), index(), 0); |
| 1049 |
GlyphSubstTableObj *table = obj->asGlyphSubstTable(); |
| 1050 |
if (table) { |
| 1051 |
Ptr<InheritedC> tem = new GlyphSubstTableC(identifier(), index(), 0); |
| 1052 |
((GlyphSubstTableC *)tem.pointer())->append(table->glyphSubstTable()); |
| 1053 |
return tem; |
| 1054 |
} |
| 1055 |
Ptr<InheritedC> tem = new GlyphSubstTableC(identifier(), index(), 1); |
| 1056 |
for (;;) { |
| 1057 |
if (obj->isNil()) |
| 1058 |
return tem; |
| 1059 |
PairObj *pair = obj->asPair(); |
| 1060 |
if (!pair) |
| 1061 |
break; |
| 1062 |
obj = pair->cdr(); |
| 1063 |
table = pair->car()->asGlyphSubstTable(); |
| 1064 |
if (!table) |
| 1065 |
break; |
| 1066 |
((GlyphSubstTableC *)tem.pointer())->append(table->glyphSubstTable()); |
| 1067 |
} |
| 1068 |
invalidValue(loc, interp); |
| 1069 |
return ConstPtr<InheritedC>(); |
| 1070 |
} |
| 1071 |
|
| 1072 |
ELObj *GlyphSubstTableC::value(VM &vm, const VarStyleObj *, Vector<size_t> &) const |
| 1073 |
{ |
| 1074 |
if (!isList_) { |
| 1075 |
if (tables_.size()) |
| 1076 |
return new (*vm.interp) GlyphSubstTableObj(tables_[0]); |
| 1077 |
else |
| 1078 |
return vm.interp->makeFalse(); |
| 1079 |
} |
| 1080 |
else { |
| 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); |
| 1087 |
protect = list; |
| 1088 |
} |
| 1089 |
return list; |
| 1090 |
} |
| 1091 |
} |
| 1092 |
|
| 1093 |
class IgnoredC : public InheritedC, private Collector::DynamicRoot { |
| 1094 |
public: |
| 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; |
| 1101 |
private: |
| 1102 |
ELObj *value_; |
| 1103 |
}; |
| 1104 |
|
| 1105 |
IgnoredC::IgnoredC(const Identifier *ident, unsigned index, ELObj *value, Interpreter &interp) |
| 1106 |
: InheritedC(ident, index), Collector::DynamicRoot(interp), value_(value) |
| 1107 |
{ |
| 1108 |
} |
| 1109 |
|
| 1110 |
void IgnoredC::set(VM &, const VarStyleObj *, FOTBuilder &fotb, |
| 1111 |
ELObj *&, Vector<size_t> &) const |
| 1112 |
{ |
| 1113 |
} |
| 1114 |
|
| 1115 |
ConstPtr<InheritedC> IgnoredC::make(ELObj *obj, const Location &, Interpreter &interp) const |
| 1116 |
{ |
| 1117 |
return new IgnoredC(identifier(), index(), obj, interp); |
| 1118 |
} |
| 1119 |
|
| 1120 |
ELObj *IgnoredC::value(VM &, const VarStyleObj *, Vector<size_t> &) const |
| 1121 |
{ |
| 1122 |
return value_; |
| 1123 |
} |
| 1124 |
|
| 1125 |
void IgnoredC::trace(Collector &c) const |
| 1126 |
{ |
| 1127 |
c.trace(value_); |
| 1128 |
} |
| 1129 |
|
| 1130 |
class CharMapC : public InheritedC, private Collector::DynamicRoot { |
| 1131 |
public: |
| 1132 |
CharMapC(const Identifier *, unsigned index, ELObj *, Interpreter &); |
| 1133 |
void set(VM &, const VarStyleObj *, FOTBuilder &, |
| 1134 |
ELObj *&, Vector<size_t> &) const; |
| 1135 |
ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const; |
| 1136 |
ELObj *value(VM &, const VarStyleObj *, Vector<size_t> &) const; |
| 1137 |
void trace(Collector &) const; |
| 1138 |
private: |
| 1139 |
ELObj *value_; |
| 1140 |
FOTBuilder::Symbol sym_; |
| 1141 |
}; |
| 1142 |
|
| 1143 |
CharMapC::CharMapC(const Identifier *ident, unsigned index, |
| 1144 |
ELObj *value, Interpreter &interp) |
| 1145 |
: InheritedC(ident, index), Collector::DynamicRoot(interp), |
| 1146 |
value_(value), sym_(FOTBuilder::symbolFalse) |
| 1147 |
{ |
| 1148 |
} |
| 1149 |
|
| 1150 |
void CharMapC::set(VM &, const VarStyleObj *, FOTBuilder &fotb, |
| 1151 |
ELObj *&, Vector<size_t> &) const |
| 1152 |
{ |
| 1153 |
fotb.setCharMap(sym_); |
| 1154 |
} |
| 1155 |
|
| 1156 |
ConstPtr<InheritedC> CharMapC::make(ELObj *obj, const Location &loc, |
| 1157 |
Interpreter &interp) const |
| 1158 |
{ |
| 1159 |
if (obj == interp.makeFalse()) |
| 1160 |
return new CharMapC(identifier(), index(), obj, interp); |
| 1161 |
FunctionObj *func = obj->asFunction(); |
| 1162 |
if (func) { |
| 1163 |
if (func->nRequiredArgs() > 1) { |
| 1164 |
interp.setNextLocation(loc); |
| 1165 |
interp.message(InterpreterMessages::missingArg); |
| 1166 |
return ConstPtr<InheritedC>(); |
| 1167 |
} |
| 1168 |
if ((func->nRequiredArgs() + func->nOptionalArgs() |
| 1169 |
+ func->restArg() ? 1 : 0) == 0) { |
| 1170 |
interp.setNextLocation(loc); |
| 1171 |
interp.message(InterpreterMessages::tooManyArgs); |
| 1172 |
return ConstPtr<InheritedC>(); |
| 1173 |
} |
| 1174 |
return new CharMapC (identifier(), index(), obj, interp); |
| 1175 |
} |
| 1176 |
if (interp.dsssl2()) { |
| 1177 |
static FOTBuilder::Symbol syms[] = { |
| 1178 |
FOTBuilder::symbolUppercase, |
| 1179 |
FOTBuilder::symbolLowercase, |
| 1180 |
FOTBuilder::symbolCapitalize, |
| 1181 |
}; |
| 1182 |
FOTBuilder::Symbol sym; |
| 1183 |
if (interp.convertEnumC(syms, SIZEOF(syms), obj, identifier(), loc, sym)) { |
| 1184 |
CharMapC *cm(new CharMapC(identifier(), index(), obj, interp)); |
| 1185 |
cm->sym_ = sym; |
| 1186 |
return cm; |
| 1187 |
} |
| 1188 |
else |
| 1189 |
return ConstPtr<InheritedC>(); |
| 1190 |
} |
| 1191 |
// Not dsssl2. |
| 1192 |
interp.setNextLocation(loc); |
| 1193 |
interp.message(InterpreterMessages::invalidCharacteristicValue, |
| 1194 |
StringMessageArg(identifier()->name())); |
| 1195 |
return ConstPtr<InheritedC>(); |
| 1196 |
} |
| 1197 |
|
| 1198 |
ELObj *CharMapC::value(VM &, const VarStyleObj *, Vector<size_t> &) const |
| 1199 |
{ |
| 1200 |
return value_; |
| 1201 |
} |
| 1202 |
|
| 1203 |
void CharMapC::trace(Collector &c) const |
| 1204 |
{ |
| 1205 |
c.trace(value_); |
| 1206 |
} |
| 1207 |
|
| 1208 |
|
| 1209 |
|
| 1210 |
class BorderC : public IgnoredC { |
| 1211 |
public: |
| 1212 |
BorderC(const Identifier *, unsigned index, ELObj *, Interpreter &); |
| 1213 |
ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const; |
| 1214 |
}; |
| 1215 |
|
| 1216 |
BorderC::BorderC(const Identifier *ident, unsigned index, ELObj *value, Interpreter &interp) |
| 1217 |
: IgnoredC(ident, index, value, interp) |
| 1218 |
{ |
| 1219 |
} |
| 1220 |
|
| 1221 |
ConstPtr<InheritedC> BorderC::make(ELObj *obj, const Location &loc, Interpreter &interp) const |
| 1222 |
{ |
| 1223 |
StyleObj *tem; |
| 1224 |
SosofoObj *sosofo = obj->asSosofo(); |
| 1225 |
if (sosofo && sosofo->tableBorderStyle(tem)) |
| 1226 |
return new BorderC(identifier(), index(), obj, interp); |
| 1227 |
bool b; |
| 1228 |
if (interp.convertBooleanC(obj, identifier(), loc, b)) { |
| 1229 |
if (b) |
| 1230 |
obj = interp.makeTrue(); |
| 1231 |
else |
| 1232 |
obj = interp.makeFalse(); |
| 1233 |
return new BorderC(identifier(), index(), obj, interp); |
| 1234 |
} |
| 1235 |
return ConstPtr<InheritedC>(); |
| 1236 |
} |
| 1237 |
|
| 1238 |
class RuleC : public IgnoredC { |
| 1239 |
public: |
| 1240 |
RuleC(const Identifier *, unsigned index, ELObj *, Interpreter &); |
| 1241 |
ConstPtr<InheritedC> make(ELObj *, const Location &, Interpreter &) const; |
| 1242 |
}; |
| 1243 |
|
| 1244 |
RuleC::RuleC(const Identifier *ident, unsigned index, ELObj *value, Interpreter &interp) |
| 1245 |
: IgnoredC(ident, index, value, interp) |
| 1246 |
{ |
| 1247 |
} |
| 1248 |
|
| 1249 |
ConstPtr<InheritedC> RuleC::make(ELObj *obj, const Location &loc, Interpreter &interp) const |
| 1250 |
{ |
| 1251 |
SosofoObj *sosofo = obj->asSosofo(); |
| 1252 |
if (sosofo && sosofo->isRule()) |
| 1253 |
return new RuleC(identifier(), index(), obj, interp); |
| 1254 |
invalidValue(loc, interp); |
| 1255 |
return ConstPtr<InheritedC>(); |
| 1256 |
} |
| 1257 |
|
| 1258 |
class InheritedCPrimitiveObj : public PrimitiveObj { |
| 1259 |
public: |
| 1260 |
void *operator new(size_t, Collector &c) { |
| 1261 |
return c.allocateObject(1); |
| 1262 |
} |
| 1263 |
static const Signature signature_; |
| 1264 |
InheritedCPrimitiveObj(const ConstPtr<InheritedC> &ic) |
| 1265 |
: PrimitiveObj(&signature_), inheritedC_(ic) { } |
| 1266 |
ELObj *primitiveCall(int, ELObj **, EvalContext &, Interpreter &, const Location &); |
| 1267 |
private: |
| 1268 |
ConstPtr<InheritedC> inheritedC_; |
| 1269 |
}; |
| 1270 |
|
| 1271 |
const Signature InheritedCPrimitiveObj::signature_ = { 0, 0, 0 }; |
| 1272 |
|
| 1273 |
ELObj *InheritedCPrimitiveObj::primitiveCall(int, ELObj **, EvalContext &ec, |
| 1274 |
Interpreter &interp, |
| 1275 |
const Location &loc) |
| 1276 |
{ |
| 1277 |
if (!interp.style()) |
| 1278 |
return interp.makeError(); |
| 1279 |
if (!ec.styleStack) { |
| 1280 |
interp.setNextLocation(loc); |
| 1281 |
interp.message(InterpreterMessages::notInCharacteristicValue); |
| 1282 |
return interp.makeError(); |
| 1283 |
} |
| 1284 |
ELObj *obj = ec.styleStack->inherited(inheritedC_, ec.specLevel, interp, |
| 1285 |
*ec.actualDependencies); |
| 1286 |
interp.makeReadOnly(obj); |
| 1287 |
return obj; |
| 1288 |
} |
| 1289 |
|
| 1290 |
class ActualCPrimitiveObj : public PrimitiveObj { |
| 1291 |
public: |
| 1292 |
void *operator new(size_t, Collector &c) { |
| 1293 |
return c.allocateObject(1); |
| 1294 |
} |
| 1295 |
static const Signature signature_; |
| 1296 |
ActualCPrimitiveObj(const ConstPtr<InheritedC> &ic) |
| 1297 |
: PrimitiveObj(&signature_), inheritedC_(ic) { } |
| 1298 |
ELObj *primitiveCall(int, ELObj **, EvalContext &, Interpreter &, const Location &); |
| 1299 |
private: |
| 1300 |
ConstPtr<InheritedC> inheritedC_; |
| 1301 |
}; |
| 1302 |
|
| 1303 |
const Signature ActualCPrimitiveObj::signature_ = { 0, 0, 0 }; |
| 1304 |
|
| 1305 |
ELObj *ActualCPrimitiveObj::primitiveCall(int, ELObj **, EvalContext &ec, Interpreter &interp, |
| 1306 |
const Location &loc) |
| 1307 |
{ |
| 1308 |
interp.requireFeature(Interpreter::actualCharacteristic, loc); |
| 1309 |
if (!interp.style()) |
| 1310 |
return interp.makeError(); |
| 1311 |
if (!ec.styleStack) { |
| 1312 |
interp.setNextLocation(loc); |
| 1313 |
interp.message(InterpreterMessages::notInCharacteristicValue); |
| 1314 |
return interp.makeError(); |
| 1315 |
} |
| 1316 |
ELObj *obj = ec.styleStack->actual(inheritedC_, loc, interp, *ec.actualDependencies); |
| 1317 |
const Char *s; |
| 1318 |
size_t n; |
| 1319 |
interp.makeReadOnly(obj); |
| 1320 |
return obj; |
| 1321 |
} |
| 1322 |
|
| 1323 |
#define INHERITED_C(name, C, init) \ |
| 1324 |
installInheritedC(name, new C(0, nInheritedC_++, init)) |
| 1325 |
#define INHERITED_C2(name, C, init1, init2) \ |
| 1326 |
installInheritedC(name, new C(0, nInheritedC_++, init1, init2)) |
| 1327 |
#define STORE_INHERITED_C2(var, name, C, init1, init2) \ |
| 1328 |
{ InheritedC *ic = new C(0, nInheritedC_++, init1, init2); \ |
| 1329 |
installInheritedC(name, ic); \ |
| 1330 |
var = ic; } |
| 1331 |
|
| 1332 |
#define IGNORED_C(name, init) INHERITED_C2(name, IgnoredC, init, *this) |
| 1333 |
|
| 1334 |
static StyleObj *makeBorderStyle(bool b, unsigned index, Interpreter &interp) |
| 1335 |
{ |
| 1336 |
Vector<ConstPtr<InheritedC> > forceSpecs; |
| 1337 |
Vector<ConstPtr<InheritedC> > specs; |
| 1338 |
specs.push_back( |
| 1339 |
new GenericBoolInheritedC(interp.lookup(interp.makeStringC("border-present?")), |
| 1340 |
index, &FOTBuilder::setBorderPresent, b)); |
| 1341 |
|
| 1342 |
StyleObj *style |
| 1343 |
= new (interp) VarStyleObj(new StyleSpec(forceSpecs, specs), 0, 0, NodePtr()); |
| 1344 |
interp.makePermanent(style); |
| 1345 |
return style; |
| 1346 |
} |
| 1347 |
|
| 1348 |
void Interpreter::installInheritedCs() |
| 1349 |
{ |
| 1350 |
INHERITED_C("font-size", FontSizeC, (unitsPerInch()*10)/72); |
| 1351 |
INHERITED_C("font-family-name", FontFamilyNameC, makeStringC("iso-serif")); |
| 1352 |
INHERITED_C2("font-weight", GenericSymbolInheritedC, &FOTBuilder::setFontWeight, |
| 1353 |
FOTBuilder::symbolMedium); |
| 1354 |
INHERITED_C2("font-posture", GenericSymbolInheritedC, &FOTBuilder::setFontPosture, |
| 1355 |
FOTBuilder::symbolUpright); |
| 1356 |
INHERITED_C2("quadding", GenericSymbolInheritedC, &FOTBuilder::setQuadding, |
| 1357 |
FOTBuilder::symbolStart); |
| 1358 |
INHERITED_C2("display-alignment", GenericSymbolInheritedC, &FOTBuilder::setDisplayAlignment, |
| 1359 |
FOTBuilder::symbolStart); |
| 1360 |
INHERITED_C2("field-align", GenericSymbolInheritedC, &FOTBuilder::setFieldAlign, |
| 1361 |
FOTBuilder::symbolStart); |
| 1362 |
INHERITED_C2("lines", GenericSymbolInheritedC, &FOTBuilder::setLines, FOTBuilder::symbolWrap); |
| 1363 |
INHERITED_C("start-indent", GenericLengthSpecInheritedC, |
| 1364 |
&FOTBuilder::setStartIndent); |
| 1365 |
INHERITED_C("first-line-start-indent", GenericLengthSpecInheritedC, |
| 1366 |
&FOTBuilder::setFirstLineStartIndent); |
| 1367 |
INHERITED_C("end-indent", GenericLengthSpecInheritedC, |
| 1368 |
&FOTBuilder::setEndIndent); |
| 1369 |
INHERITED_C("last-line-end-indent", GenericLengthSpecInheritedC, |
| 1370 |
&FOTBuilder::setLastLineEndIndent); |
| 1371 |
INHERITED_C2("line-spacing", GenericLengthSpecInheritedC, |
| 1372 |
&FOTBuilder::setLineSpacing, unitsPerInch()*12/72); |
| 1373 |
INHERITED_C("field-width", GenericLengthSpecInheritedC, |
| 1374 |
&FOTBuilder::setFieldWidth); |
| 1375 |
INHERITED_C("left-margin", GenericLengthInheritedC, |
| 1376 |
&FOTBuilder::setLeftMargin); |
| 1377 |
INHERITED_C("right-margin", GenericLengthInheritedC, |
| 1378 |
&FOTBuilder::setRightMargin); |
| 1379 |
INHERITED_C("top-margin", GenericLengthInheritedC, |
| 1380 |
&FOTBuilder::setTopMargin); |
| 1381 |
INHERITED_C("bottom-margin", GenericLengthInheritedC, |
| 1382 |
&FOTBuilder::setBottomMargin); |
| 1383 |
INHERITED_C("header-margin", GenericLengthInheritedC, |
| 1384 |
&FOTBuilder::setHeaderMargin); |
| 1385 |
INHERITED_C("footer-margin", GenericLengthInheritedC, |
| 1386 |
&FOTBuilder::setFooterMargin); |
| 1387 |
INHERITED_C2("page-width", GenericLengthInheritedC, |
| 1388 |
&FOTBuilder::setPageWidth, |
| 1389 |
unitsPerInch()*8 + unitsPerInch()/2); |
| 1390 |
INHERITED_C2("page-height", GenericLengthInheritedC, |
| 1391 |
&FOTBuilder::setPageHeight, |
| 1392 |
unitsPerInch()*11); |
| 1393 |
INHERITED_C2("color", ColorC, new (*this) DeviceRGBColorObj(0, 0, 0), *this); |
| 1394 |
INHERITED_C2("background-color", BackgroundColorC, 0, *this); |
| 1395 |
INHERITED_C2("border-present?", GenericBoolInheritedC, |
| 1396 |
&FOTBuilder::setBorderPresent, 1); |
| 1397 |
borderTrueStyle_ = makeBorderStyle(1, nInheritedC_ - 1, *this); |
| 1398 |
borderFalseStyle_ = makeBorderStyle(0, nInheritedC_ - 1, *this); |
| 1399 |
STORE_INHERITED_C2(tableBorderC_, "table-border", BorderC, makeFalse(), *this); |
| 1400 |
STORE_INHERITED_C2(cellBeforeRowBorderC_, "cell-before-row-border", |
| 1401 |
BorderC, makeFalse(), *this); |
| 1402 |
STORE_INHERITED_C2(cellAfterRowBorderC_, "cell-after-row-border", |
| 1403 |
BorderC, makeFalse(), *this); |
| 1404 |
STORE_INHERITED_C2(cellBeforeColumnBorderC_, "cell-before-column-border", |
| 1405 |
BorderC, makeFalse(), *this); |
| 1406 |
STORE_INHERITED_C2(cellAfterColumnBorderC_, "cell-after-column-border", |
| 1407 |
BorderC, makeFalse(), *this); |
| 1408 |
STORE_INHERITED_C2(fractionBarC_, "fraction-bar", |
| 1409 |
RuleC, lookup(makeStringC("rule"))->flowObj(), *this); |
| 1410 |
INHERITED_C2("line-thickness", GenericLengthInheritedC, &FOTBuilder::setLineThickness, |
| 1411 |
unitsPerInch()/72); |
| 1412 |
INHERITED_C2("cell-before-row-margin", GenericLengthInheritedC, |
| 1413 |
&FOTBuilder::setCellBeforeRowMargin, 0); |
| 1414 |
INHERITED_C2("cell-after-row-margin", GenericLengthInheritedC, |
| 1415 |
&FOTBuilder::setCellAfterRowMargin, 0); |
| 1416 |
INHERITED_C2("cell-before-column-margin", GenericLengthInheritedC, |
| 1417 |
&FOTBuilder::setCellBeforeColumnMargin, 0); |
| 1418 |
INHERITED_C2("cell-after-column-margin", GenericLengthInheritedC, |
| 1419 |
&FOTBuilder::setCellAfterColumnMargin, 0); |
| 1420 |
INHERITED_C2("line-sep", GenericLengthInheritedC, |
| 1421 |
&FOTBuilder::setLineSep, unitsPerInch()/72); |
| 1422 |
INHERITED_C2("box-size-before", GenericLengthInheritedC, &FOTBuilder::setBoxSizeBefore, |
| 1423 |
8*unitsPerInch()/72); |
| 1424 |
INHERITED_C2("box-size-after", GenericLengthInheritedC, &FOTBuilder::setBoxSizeAfter, |
| 1425 |
4*unitsPerInch()/72); |
| 1426 |
INHERITED_C2("position-point-shift", GenericLengthSpecInheritedC, |
| 1427 |
&FOTBuilder::setPositionPointShift, 0); |
| 1428 |
INHERITED_C2("start-margin", GenericLengthSpecInheritedC, &FOTBuilder::setStartMargin, 0); |
| 1429 |
INHERITED_C2("end-margin", GenericLengthSpecInheritedC, &FOTBuilder::setEndMargin, 0); |
| 1430 |
INHERITED_C2("sideline-sep", GenericLengthSpecInheritedC, &FOTBuilder::setSidelineSep, |
| 1431 |
4*unitsPerInch()/72); |
| 1432 |
INHERITED_C2("asis-wrap-indent", GenericLengthSpecInheritedC, &FOTBuilder::setAsisWrapIndent, 0); |
| 1433 |
INHERITED_C2("line-number-sep", GenericLengthSpecInheritedC, &FOTBuilder::setLineNumberSep, 0); |
| 1434 |
INHERITED_C2("last-line-justify-limit", GenericLengthSpecInheritedC, |
| 1435 |
&FOTBuilder::setLastLineJustifyLimit, 0); |
| 1436 |
INHERITED_C2("justify-glyph-space-max-add", GenericLengthSpecInheritedC, |
| 1437 |
&FOTBuilder::setJustifyGlyphSpaceMaxAdd, 0); |
| 1438 |
INHERITED_C2("justify-glyph-space-max-remove", GenericLengthSpecInheritedC, |
| 1439 |
&FOTBuilder::setJustifyGlyphSpaceMaxRemove, 0); |
| 1440 |
INHERITED_C2("table-corner-radius", GenericLengthSpecInheritedC, |
| 1441 |
&FOTBuilder::setTableCornerRadius, 3*unitsPerInch()/72); |
| 1442 |
INHERITED_C2("box-corner-radius", GenericLengthSpecInheritedC, |
| 1443 |
&FOTBuilder::setBoxCornerRadius, 3*unitsPerInch()/72); |
| 1444 |
INHERITED_C2("marginalia-sep", GenericLengthSpecInheritedC, |
| 1445 |
&FOTBuilder::setMarginaliaSep, 0); |
| 1446 |
INHERITED_C2("inhibit-line-breaks?", GenericBoolInheritedC, &FOTBuilder::setInhibitLineBreaks, 0); |
| 1447 |
INHERITED_C2("hyphenate?", GenericBoolInheritedC, &FOTBuilder::setHyphenate, 0); |
| 1448 |
INHERITED_C2("kern?", GenericBoolInheritedC, &FOTBuilder::setKern, 0); |
| 1449 |
INHERITED_C2("ligature?", GenericBoolInheritedC, &FOTBuilder::setLigature, 0); |
| 1450 |
INHERITED_C2("score-spaces?", GenericBoolInheritedC, &FOTBuilder::setScoreSpaces, 0); |
| 1451 |
INHERITED_C2("float-out-sidelines?", GenericBoolInheritedC, &FOTBuilder::setFloatOutSidelines, 0); |
| 1452 |
INHERITED_C2("float-out-marginalia?", GenericBoolInheritedC, &FOTBuilder::setFloatOutMarginalia, 0); |
| 1453 |
INHERITED_C2("float-out-line-numbers?", GenericBoolInheritedC, &FOTBuilder::setFloatOutLineNumbers, 0); |
| 1454 |
INHERITED_C2("cell-background?", GenericBoolInheritedC, &FOTBuilder::setCellBackground, 0); |
| 1455 |
INHERITED_C2("span-weak?", GenericBoolInheritedC, &FOTBuilder::setSpanWeak, 0); |
| 1456 |
INHERITED_C2("ignore-record-end?", GenericBoolInheritedC, &FOTBuilder::setIgnoreRecordEnd, 0); |
| 1457 |
INHERITED_C2("numbered-lines?", GenericBoolInheritedC, &FOTBuilder::setNumberedLines, 1); |
| 1458 |
INHERITED_C2("hanging-punct?", GenericBoolInheritedC, &FOTBuilder::setHangingPunct, 0); |
| 1459 |
INHERITED_C2("box-open-end?", GenericBoolInheritedC, &FOTBuilder::setBoxOpenEnd, 0); |
| 1460 |
INHERITED_C2("side-by-side-overlap-control", GenericSymbolInheritedC, &FOTBuilder::setSideBySideOverlapControl, |
| 1461 |
FOTBuilder::symbolIndent); |
| 1462 |
INHERITED_C2("side-by-side-pre-align", GenericSymbolInheritedC, &FOTBuilder::setSideBySidePreAlign, |
| 1463 |
FOTBuilder::symbolInitial); |
| 1464 |
INHERITED_C2("side-by-side-post-align", GenericSymbolInheritedC, &FOTBuilder::setSideBySidePostAlign, |
| 1465 |
FOTBuilder::symbolInitial); |
| 1466 |
INHERITED_C2("truncate-leader?", GenericBoolInheritedC, &FOTBuilder::setTruncateLeader, 0); |
| 1467 |
INHERITED_C2("align-leader?", GenericBoolInheritedC, &FOTBuilder::setAlignLeader, 1); |
| 1468 |
INHERITED_C2("table-part-omit-middle-header?", GenericBoolInheritedC, |
| 1469 |
&FOTBuilder::setTablePartOmitMiddleHeader, 0); |
| 1470 |
INHERITED_C2("table-part-omit-middle-footer?", GenericBoolInheritedC, |
| 1471 |
&FOTBuilder::setTablePartOmitMiddleFooter, 0); |
| 1472 |
INHERITED_C2("border-omit-at-break?", GenericBoolInheritedC, &FOTBuilder::setBorderOmitAtBreak, 0); |
| 1473 |
INHERITED_C2("principal-mode-simultaneous?", GenericBoolInheritedC, |
| 1474 |
&FOTBuilder::setPrincipalModeSimultaneous, 0); |
| 1475 |
INHERITED_C2("marginalia-keep-with-previous?", GenericBoolInheritedC, |
| 1476 |
&FOTBuilder::setMarginaliaKeepWithPrevious, 0); |
| 1477 |
INHERITED_C2("grid-equidistant-rows?", GenericBoolInheritedC, &FOTBuilder::setGridEquidistantRows, 0); |
| 1478 |
INHERITED_C2("grid-equidistant-columns?", GenericBoolInheritedC, &FOTBuilder::setGridEquidistantColumns, 0); |
| 1479 |
INHERITED_C2("line-join", GenericSymbolInheritedC, &FOTBuilder::setLineJoin, |
| 1480 |
FOTBuilder::symbolMiter); |
| 1481 |
INHERITED_C2("line-cap", GenericSymbolInheritedC, &FOTBuilder::setLineCap, |
| 1482 |
FOTBuilder::symbolButt); |
| 1483 |
INHERITED_C2("line-number-side", GenericSymbolInheritedC, &FOTBuilder::setLineNumberSide, |
| 1484 |
FOTBuilder::symbolStart); |
| 1485 |
INHERITED_C2("kern-mode", GenericSymbolInheritedC, &FOTBuilder::setKernMode, |
| 1486 |
FOTBuilder::symbolNormal); |
| 1487 |
INHERITED_C2("input-whitespace-treatment", GenericSymbolInheritedC, |
| 1488 |
&FOTBuilder::setInputWhitespaceTreatment, FOTBuilder::symbolPreserve); |
| 1489 |
INHERITED_C2("filling-direction", GenericSymbolInheritedC, &FOTBuilder::setFillingDirection, |
| 1490 |
FOTBuilder::symbolTopToBottom ); |
| 1491 |
INHERITED_C2("writing-mode", GenericSymbolInheritedC, &FOTBuilder::setWritingMode, |
| 1492 |
FOTBuilder::symbolLeftToRight ); |
| 1493 |
INHERITED_C2("last-line-quadding", GenericSymbolInheritedC, &FOTBuilder::setLastLineQuadding, |
| 1494 |
FOTBuilder::symbolRelative); |
| 1495 |
INHERITED_C2("math-display-mode", GenericSymbolInheritedC, &FOTBuilder::setMathDisplayMode, |
| 1496 |
FOTBuilder::symbolDisplay); |
| 1497 |
INHERITED_C2("script-pre-align", GenericSymbolInheritedC, &FOTBuilder::setScriptPreAlign, |
| 1498 |
FOTBuilder::symbolIndependent); |
| 1499 |
INHERITED_C2("script-post-align", GenericSymbolInheritedC, &FOTBuilder::setScriptPostAlign, |
| 1500 |
FOTBuilder::symbolIndependent); |
| 1501 |
INHERITED_C2("script-mid-sup-align", GenericSymbolInheritedC, &FOTBuilder::setScriptMidSupAlign, |
| 1502 |
FOTBuilder::symbolCenter); |
| 1503 |
INHERITED_C2("script-mid-sub-align", GenericSymbolInheritedC, &FOTBuilder::setScriptMidSubAlign, |
| 1504 |
FOTBuilder::symbolCenter); |
| 1505 |
INHERITED_C2("numerator-align", GenericSymbolInheritedC, &FOTBuilder::setNumeratorAlign, |
| 1506 |
FOTBuilder::symbolCenter); |
| 1507 |
INHERITED_C2("denominator-align", GenericSymbolInheritedC, &FOTBuilder::setDenominatorAlign, |
| 1508 |
FOTBuilder::symbolCenter); |
| 1509 |
INHERITED_C2("grid-position-cell-type", GenericSymbolInheritedC, &FOTBuilder::setGridPositionCellType, |
| 1510 |
FOTBuilder::symbolRowMajor); |
| 1511 |
INHERITED_C2("grid-column-alignment", GenericSymbolInheritedC, &FOTBuilder::setGridColumnAlignment, |
| 1512 |
FOTBuilder::symbolCenter); |
| 1513 |
INHERITED_C2("grid-row-alignment", GenericSymbolInheritedC, &FOTBuilder::setGridRowAlignment, |
| 1514 |
FOTBuilder::symbolCenter); |
| 1515 |
INHERITED_C2("box-type", GenericSymbolInheritedC, &FOTBuilder::setBoxType, |
| 1516 |
FOTBuilder::symbolBorder); |
| 1517 |
INHERITED_C2("glyph-alignment-mode", GenericSymbolInheritedC, &FOTBuilder::setGlyphAlignmentMode, |
| 1518 |
FOTBuilder::symbolFont); |
| 1519 |
INHERITED_C2("box-border-alignment", GenericSymbolInheritedC, &FOTBuilder::setBoxBorderAlignment, |
| 1520 |
FOTBuilder::symbolOutside); |
| 1521 |
INHERITED_C2("cell-row-alignment", GenericSymbolInheritedC, &FOTBuilder::setCellRowAlignment, |
| 1522 |
FOTBuilder::symbolStart); |
| 1523 |
INHERITED_C2("border-alignment", GenericSymbolInheritedC, &FOTBuilder::setBorderAlignment, |
| 1524 |
FOTBuilder::symbolCenter); |
| 1525 |
INHERITED_C2("sideline-side", GenericSymbolInheritedC, &FOTBuilder::setSidelineSide, |
| 1526 |
FOTBuilder::symbolStart); |
| 1527 |
INHERITED_C2("hyphenation-keep", GenericSymbolInheritedC, &FOTBuilder::setHyphenationKeep, |
| 1528 |
FOTBuilder::symbolFalse); |
| 1529 |
INHERITED_C2("font-structure", GenericSymbolInheritedC, &FOTBuilder::setFontStructure, |
| 1530 |
FOTBuilder::symbolSolid); |
| 1531 |
INHERITED_C2("font-proportionate-width", GenericSymbolInheritedC, |
| 1532 |
&FOTBuilder::setFontProportionateWidth, FOTBuilder::symbolMedium); |
| 1533 |
INHERITED_C2("cell-crossed", GenericSymbolInheritedC, &FOTBuilder::setCellCrossed, |
| 1534 |
FOTBuilder::symbolFalse); |
| 1535 |
INHERITED_C2("marginalia-side", GenericSymbolInheritedC, &FOTBuilder::setMarginaliaSide, |
| 1536 |
FOTBuilder::symbolStart); |
| 1537 |
INHERITED_C2("layer", GenericIntegerInheritedC, &FOTBuilder::setLayer, 0); |
| 1538 |
INHERITED_C2("background-layer", GenericIntegerInheritedC, &FOTBuilder::setBackgroundLayer, -1); |
| 1539 |
INHERITED_C2("border-priority", GenericIntegerInheritedC, &FOTBuilder::setBorderPriority, 0); |
| 1540 |
INHERITED_C2("line-repeat", GenericIntegerInheritedC, &FOTBuilder::setLineRepeat, 1); |
| 1541 |
INHERITED_C2("span", GenericIntegerInheritedC, &FOTBuilder::setSpan, 1); |
| 1542 |
INHERITED_C2("min-leader-repeat", GenericIntegerInheritedC, &FOTBuilder::setMinLeaderRepeat, 1); |
| 1543 |
INHERITED_C2("hyphenation-remain-char-count", GenericIntegerInheritedC, |
| 1544 |
&FOTBuilder::setHyphenationRemainCharCount, 2); |
| 1545 |
INHERITED_C2("hyphenation-push-char-count", GenericIntegerInheritedC, |
| 1546 |
&FOTBuilder::setHyphenationPushCharCount, 2); |
| 1547 |
INHERITED_C2("widow-count", GenericIntegerInheritedC, &FOTBuilder::setWidowCount, 2); |
| 1548 |
INHERITED_C2("orphan-count", GenericIntegerInheritedC, &FOTBuilder::setOrphanCount, 2); |
| 1549 |
// #f or strictly positive integer |
| 1550 |
INHERITED_C2("expand-tabs?", GenericMaybeIntegerInheritedC, |
| 1551 |
&FOTBuilder::setExpandTabs, 8); |
| 1552 |
INHERITED_C2("hyphenation-ladder-count", GenericMaybeIntegerInheritedC, |
| 1553 |
&FOTBuilder::setHyphenationLadderCount, 0); |
| 1554 |
INHERITED_C("background-tile", GenericPublicIdInheritedC, &FOTBuilder::setBackgroundTile); |
| 1555 |
INHERITED_C("line-breaking-method", GenericPublicIdInheritedC, &FOTBuilder::setLineBreakingMethod); |
| 1556 |
INHERITED_C("line-composition-method", GenericPublicIdInheritedC, &FOTBuilder::setLineCompositionMethod); |
| 1557 |
INHERITED_C("implicit-bidi-method", GenericPublicIdInheritedC, &FOTBuilder::setImplicitBidiMethod); |
| 1558 |
INHERITED_C("glyph-subst-method", GenericPublicIdInheritedC, &FOTBuilder::setGlyphSubstMethod); |
| 1559 |
INHERITED_C("glyph-reorder-method", GenericPublicIdInheritedC, &FOTBuilder::setGlyphReorderMethod); |
| 1560 |
INHERITED_C("hyphenation-method", GenericPublicIdInheritedC, &FOTBuilder::setHyphenationMethod); |
| 1561 |
INHERITED_C("table-auto-width-method", GenericPublicIdInheritedC, &FOTBuilder::setTableAutoWidthMethod); |
| 1562 |
INHERITED_C("font-name", GenericPublicIdInheritedC, &FOTBuilder::setFontName); |
| 1563 |
// 2 letter symbol or #f |
| 1564 |
INHERITED_C("language", GenericLetter2InheritedC, &FOTBuilder::setLanguage); |
| 1565 |
INHERITED_C("country", GenericLetter2InheritedC, &FOTBuilder::setCountry); |
| 1566 |
// Ignored characteristics |
| 1567 |
ELObjDynamicRoot length0(*this, new (*this) LengthObj(0)); |
| 1568 |
// #f or length-spec |
| 1569 |
INHERITED_C("min-pre-line-spacing", GenericOptLengthSpecInheritedC, &FOTBuilder::setMinPreLineSpacing); |
| 1570 |
INHERITED_C("min-post-line-spacing", GenericOptLengthSpecInheritedC, &FOTBuilder::setMinPostLineSpacing); |
| 1571 |
INHERITED_C("min-leading", GenericOptLengthSpecInheritedC, &FOTBuilder::setMinLeading); |
| 1572 |
// inline spaces |
| 1573 |
INHERITED_C("escapement-space-before", GenericInlineSpaceInheritedC, &FOTBuilder::setEscapementSpaceBefore); |
| 1574 |
INHERITED_C("escapement-space-after", GenericInlineSpaceInheritedC, &FOTBuilder::setEscapementSpaceAfter); |
| 1575 |
// #f or glyph-subst-table |
| 1576 |
INHERITED_C("glyph-subst-table", GlyphSubstTableC, 0); |
| 1577 |
|
| 1578 |
// #f or inline-space |
| 1579 |
INHERITED_C("inline-space-space", GenericOptInlineSpaceInheritedC, &FOTBuilder::setInlineSpaceSpace); |
| 1580 |
// integers |
| 1581 |
// float |
| 1582 |
IGNORED_C("line-miter-limit", makeInteger(10)); |
| 1583 |
// #f or percentage |
| 1584 |
IGNORED_C("alignment-point-offset", makeInteger(50)); |
| 1585 |
// char |
| 1586 |
IGNORED_C("hyphenation-char", new (*this) CharObj('-')); |
| 1587 |
// char or #f |
| 1588 |
IGNORED_C("asis-truncate-char", makeFalse()); |
| 1589 |
IGNORED_C("asis-wrap-char", makeFalse()); |
| 1590 |
// #f, #t or char |
| 1591 |
IGNORED_C("first-line-align", makeFalse()); |
| 1592 |
// list of strings |
| 1593 |
IGNORED_C("hyphenation-exceptions", makeNil()); |
| 1594 |
// set of corners |
| 1595 |
IGNORED_C("box-corner-rounded", makeFalse()); |
| 1596 |
IGNORED_C("table-corner-rounded", makeFalse()); |
| 1597 |
// list of lengths |
| 1598 |
IGNORED_C("line-dash", new (*this) PairObj(length0, makeNil())); |
| 1599 |
// list of glyphs/chars |
| 1600 |
IGNORED_C("allowed-ligatures", makeNil()); |
| 1601 |
// #f or sosofo |
| 1602 |
IGNORED_C("line-number", makeFalse()); |
| 1603 |
// integer or 'force |
| 1604 |
IGNORED_C("line-spacing-priority", makeInteger(0)); |
| 1605 |
// procedure or #f |
| 1606 |
STORE_INHERITED_C2(charMapC_, "char-map", CharMapC, makeFalse(), *this); |
| 1607 |
} |
| 1608 |
|
| 1609 |
void Interpreter::installInheritedC(const char *s, InheritedC *ic) |
| 1610 |
{ |
| 1611 |
StringC name(makeStringC(s)); |
| 1612 |
Identifier *ident = lookup(name); |
| 1613 |
ic->setIdentifier(ident); |
| 1614 |
ident->setInheritedC(ic); |
| 1615 |
installInheritedCProc(ident); |
| 1616 |
if (dsssl2() && name.size() && name[name.size() - 1] == '?') { |
| 1617 |
name.resize(name.size() - 1); |
| 1618 |
Identifier *ident2 = lookup(name); |
| 1619 |
ASSERT(ident2->inheritedC().isNull()); |
| 1620 |
ident2->setInheritedC(ic); |
| 1621 |
installInheritedCProc(ident2); |
| 1622 |
} |
| 1623 |
} |
| 1624 |
|
| 1625 |
void Interpreter::installExtensionInheritedC(Identifier *ident, |
| 1626 |
const StringC &pubid, |
| 1627 |
const Location &loc) |
| 1628 |
{ |
| 1629 |
ConstPtr<InheritedC> ic; |
| 1630 |
if (pubid.size() != 0 && fotbDescr_.extensions) { |
| 1631 |
for (const FOTBuilder::Extension *ep = fotbDescr_.extensions; |
| 1632 |
ep->pubid; ep++) { |
| 1633 |
if (pubid == ep->pubid) { |
| 1634 |
if (ep->boolSetter) |
| 1635 |
ic = new ExtensionBoolInheritedC(ident, nInheritedC_++, ep->boolSetter); |
| 1636 |
else if (ep->stringSetter) |
| 1637 |
ic = new ExtensionStringInheritedC(ident, nInheritedC_++, ep->stringSetter); |
| 1638 |
else if (ep->integerSetter) |
| 1639 |
ic = new ExtensionIntegerInheritedC(ident, nInheritedC_++, ep->integerSetter); |
| 1640 |
else if (ep->lengthSetter) |
| 1641 |
ic = new ExtensionLengthInheritedC(ident, nInheritedC_++, ep->lengthSetter); |
| 1642 |
break; |
| 1643 |
} |
| 1644 |
} |
| 1645 |
} |
| 1646 |
if (ic.isNull()) |
| 1647 |
// FIXME should call FOTBuilder with PublicId argument |
| 1648 |
ic = new IgnoredC(ident, nInheritedC_++, makeFalse(), *this); |
| 1649 |
ident->setInheritedC(ic, currentPartIndex(), loc); |
| 1650 |
installInheritedCProc(ident); |
| 1651 |
} |
| 1652 |
|
| 1653 |
void Interpreter::installInheritedCProc(const Identifier *ident) |
| 1654 |
{ |
| 1655 |
const ConstPtr<InheritedC> &ic = ident->inheritedC(); |
| 1656 |
StringC tem(makeStringC("inherited-")); |
| 1657 |
tem += ident->name(); |
| 1658 |
Identifier *inhIdent = lookup(tem); |
| 1659 |
PrimitiveObj *prim = new (*this) InheritedCPrimitiveObj(ic); |
| 1660 |
makePermanent(prim); |
| 1661 |
prim->setIdentifier(inhIdent); |
| 1662 |
inhIdent->setValue(prim); |
| 1663 |
tem = makeStringC("actual-"); |
| 1664 |
tem += ident->name(); |
| 1665 |
Identifier *actIdent = lookup(tem); |
| 1666 |
prim = new (*this) ActualCPrimitiveObj(ic); |
| 1667 |
makePermanent(prim); |
| 1668 |
prim->setIdentifier(actIdent); |
| 1669 |
actIdent->setValue(prim); |
| 1670 |
} |
| 1671 |
|
| 1672 |
#ifdef DSSSL_NAMESPACE |
| 1673 |
} |
| 1674 |
#endif |