Annotation of parser3/src/types/pa_wcontext.C, revision 1.3
1.1 paf 1: /*
2: Parser
3: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.2 paf 4: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.1 paf 5:
1.3 ! paf 6: $Id: pa_wcontext.C,v 1.2 2001/03/11 08:16:38 paf Exp $
1.1 paf 7: */
8:
9: #include "pa_wcontext.h"
10: #include "pa_exception.h"
1.3 ! paf 11: #include "pa_request.h"
1.1 paf 12:
13: // appends a fstring to result
14: void WContext::write(const String& astring, String::Untaint_lang lang) {
15: fstring.append(astring, lang);
16: }
17:
18: // if value is VString writes fstring,
19: // else writes Value; raises an error if already
20: void WContext::write(Value& avalue, String::Untaint_lang lang) {
21: const String *fstring=avalue.get_string();
22: if(fstring)
23: write(*fstring, lang);
24: else
1.3 ! paf 25: if(fvalue) { // already have value?
! 26: if(avalue.name()==UNNAMED_NAME)
! 27: THROW(0,0, // must not construct twice
! 28: &fvalue->name(),
! 29: "(%s) may not be overwritten with '%s' (%s), use constructor instead",
! 30: fvalue->type(), avalue.name().cstr(), avalue.type());
! 31: else
! 32: THROW(0,0, // must not construct twice
! 33: &avalue.name(),
! 34: "(%s) illegal assignment attempt to '%s' (%s), use constructor instead",
! 35: avalue.type(), fvalue->name().cstr(), fvalue->type());
! 36: } else {
1.1 paf 37: fvalue=&avalue;
1.3 ! paf 38: // not constructing anymore [if were constructing]
! 39: // so to allow method calls after real constructor-method call
! 40: // sample:
! 41: // $complex[
! 42: // $class:constructor[$i]
! 43: // ^i.inc[] ^rem{allow such calls}
! 44: // $field[$1]
! 45: fconstructing=false;
! 46: }
1.1 paf 47: }
48:
E-mail: