Annotation of parser3/src/types/pa_venv.C, revision 1.16
1.2 paf 1: /** @file
2: Parser: @b env class.
3:
1.16 ! moko 4: Copyright (c) 2001-2015 Art. Lebedev Studio (http://www.artlebedev.com)
1.2 paf 5: Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
6: */
7:
8: #include "pa_venv.h"
9: #include "pa_vstring.h"
1.13 misha 10: #include "pa_vhash.h"
1.2 paf 11: #include "pa_version.h"
12:
1.16 ! moko 13: volatile const char * IDENT_PA_PA_VENV_C="$Id: pa_venv.C,v 1.15 2015/04/02 22:04:41 moko Exp $" IDENT_PA_VENV_H;
1.12 moko 14:
1.4 misha 15: #define PARSER_VERSION_ELEMENT_NAME "PARSER_VERSION"
1.13 misha 16: #define ENV_FIELDS_ELEMENT_NAME "fields"
1.4 misha 17:
1.2 paf 18: static const String parser_version(PARSER_VERSION);
19:
1.11 misha 20: Value* VEnv::get_element(const String& aname) {
1.14 misha 21: #ifndef OPTIMIZE_BYTECODE_GET_ELEMENT__SPECIAL
1.6 misha 22: // $env:CLASS
1.5 misha 23: if(aname==CLASS_NAME)
24: return this;
25:
1.6 misha 26: // $env:CLASS_NAME
1.5 misha 27: if(aname==CLASS_NAMETEXT)
28: return new VString(env_class_name);
1.14 misha 29: #endif
1.5 misha 30:
1.2 paf 31: // $env:PARSER_VERSION
1.4 misha 32: if(aname==PARSER_VERSION_ELEMENT_NAME)
1.2 paf 33: return new VString(parser_version);
34:
1.15 moko 35: // $env:fields
1.13 misha 36: if(aname==ENV_FIELDS_ELEMENT_NAME){
37: HashStringValue *result=new HashStringValue();
1.15 moko 38: for(SAPI::Env::Iterator i(finfo); i; i.next() )
39: result->put(
40: i.key(),
41: new VString(*new String(i.value(), String::L_TAINTED))
42: );
1.13 misha 43: return new VHash(*result);
44: }
45:
1.6 misha 46: // $env:field
1.15 moko 47: if(const char* value=SAPI::Env::get(finfo, aname.cstr())){
48: return new VString(*new String(value, String::L_TAINTED));
1.7 misha 49: }
1.6 misha 50:
51: return 0;
1.3 paf 52: }
E-mail: