metal/metal_class.php - annotate - 1.71
Annotation of metal/metal_class.php, revision 1.71
1.1 mlemos 1: <?
2: if(!defined("METAL_CLASS_INCLUDED"))
3: {
4: define("METAL_CLASS_INCLUDED",1);
5:
6: /*
7: * metal_class.php
8: *
1.71 ! mlemos 9: * @(#) $Header: /cvsroot/metal/metal_class.php,v 1.70 2001/11/25 04:21:37 mlemos Exp $
1.1 mlemos 10: *
11: */
12:
13: class metal_class_class extends metal_base_class
14: {
1.16 mlemos 15: var $classes=array();
1.17 mlemos 16: var $subclasses=array();
1.42 mlemos 17: var $current_class=0;
18: var $current_function="";
1.43 mlemos 19: var $current_argument="";
20: var $current_argument_number=0;
1.44 mlemos 21: var $current_variable="";
1.49 mlemos 22: var $current_subclass=0;
1.44 mlemos 23:
24: Function GetDocumentation(&$scope,&$compiler,&$code,&$attributes,$element_path)
25: {
26: Unset($idiom);
27: $documentation=array();
28: $documentation_elements=$code->structure[$element_path]["Elements"];
29: for($documentation_element=0;$documentation_element<$documentation_elements;$documentation_element++)
30: {
31: $documentation_element_path=$element_path.",$documentation_element";
32: $data=$code->structure[$documentation_element_path];
33: if(GetType($data)=="array")
34: {
35: switch($data["Tag"])
36: {
37: case "idiom":
38: if(IsSet($idiom))
39: {
40: $compiler->SetElementError($attributes->file,$documentation_element_path,"it was defined the documentation idiom more than once");
41: return(0);
42: }
43: if(!$compiler->GetValidName($attributes->file,$documentation_element_path,&$idiom,"it was not specified a valid class documentation idiom option"))
44: return(0);
45: if(IsSet($scope["documentation"][$idiom]))
46: {
47: $compiler->SetElementError($attributes->file,$documentation_element_path,"it was specified the idiom of an already defined class documentation section");
48: return(0);
49: }
50: break;
51: default:
52: if(IsSet($documentation[$data["Tag"]]))
53: {
54: $compiler->SetElementError($attributes->file,$documentation_element_path,"it was specified the documentation tag ".$data["Tag"]." more than once");
55: return(0);
56: }
57: $compiler->CopyEmptyContext(&$attributes,&$documentation[$data["Tag"]]);
58: $documentation[$data["Tag"]]->path=$documentation_element_path;
59: break;
60: }
61: }
62: else
63: {
64: if(!$compiler->CheckWhiteSpace($attributes->file,$data,$documentation_element_path))
65: return(0);
66: }
67: }
68: if(!IsSet($idiom))
69: {
70: $compiler->SetElementError($attributes->file,$element_path,"it was not defined the class documentation idiom");
71: return(0);
72: }
73: $scope["documentation"][$idiom]=$documentation;
74: return(1);
75: }
1.1 mlemos 76:
1.17 mlemos 77: Function SetupClass(&$compiler,&$code,&$attributes)
78: {
79: $index=count($this->classes);
80: $this->classes[$index]["function_name"]="";
81: $this->classes[$index]["return_type"]="";
82: $this->classes[$index]["return_value_set"]=0;
83: $this->classes[$index]["staticload"]=0;
1.45 mlemos 84: $this->classes[$index]["types"]=array();
1.17 mlemos 85: $this->classes[$index]["functions"]=array();
86: $this->classes[$index]["variables"]=array();
1.33 mlemos 87: $this->classes[$index]["declarationfile"]=$attributes->file;
88: $this->classes[$index]["declarationpath"]=$attributes->path;
1.17 mlemos 89: $parent=0;
1.1 mlemos 90: $elements=$code->structure[$attributes->path]["Elements"];
91: for($element=0;$element<$elements;$element++)
92: {
93: $element_path=$attributes->path.",$element";
94: $data=$code->structure[$element_path];
95: if(GetType($data)=="array")
96: {
97: switch($data["Tag"])
98: {
1.24 mlemos 99: case "parent":
100: if(!$compiler->GetValidName($attributes->file,$element_path,&$parent_name,"it was not specified a valid class parent name argument"))
101: return(0);
102: if(count($this->classes[$index]["functions"]))
103: {
104: $compiler->SetElementError($attributes->file,$element_path,"it was attempted to define the name of the parent class after having declared class functions");
105: return(0);
106: }
107: if(count($this->classes[$index]["variables"]))
108: {
109: $compiler->SetElementError($attributes->file,$element_path,"it was attempted to define the name of the parent class after having declared class variables");
110: return(0);
111: }
112: if(!IsSet($this->subclasses[$parent_name]))
113: {
114: $compiler->SetElementError($attributes->file,$element_path,"it was not specified the name of an existing parent class");
115: return(0);
116: }
117: if($parent==$index)
118: {
119: $compiler->SetElementError($attributes->file,$element_path,"it was not specified that the parent class is the class itself");
120: return(0);
121: }
122: $parent=$this->subclasses[$parent_name];
123: break;
1.17 mlemos 124: case "name":
125: if(IsSet($this->classes[$index]["name"]))
126: {
127: $compiler->SetElementError($attributes->file,$element_path,"it was defined the class name more than once");
128: return(0);
129: }
130: if(!$compiler->GetValidName($attributes->file,$element_path,&$class_name,"it was not specified a valid class name argument"))
131: return(0);
132: if(IsSet($this->subclasses[$class_name]))
133: {
1.33 mlemos 134: if(!strcmp($this->classes[$this->subclasses[$class_name]]["declarationfile"],$attributes->file)
135: && !strcmp($this->classes[$this->subclasses[$class_name]]["declarationpath"],$attributes->path))
136: {
137: Unset($this->classes[$index]);
138: return(1);
139: }
140: $compiler->SetElementError($attributes->file,$element_path,"it was specified a subclass name (\"$class_name\") of an existing class");
1.17 mlemos 141: return(0);
142: }
143: $this->classes[$index]["name"]=$class_name;
144: $this->subclasses[$class_name]=$index;
145: break;
1.12 mlemos 146: case "function":
1.1 mlemos 147: Unset($name);
148: $function=array();
149: $function_elements=$code->structure[$element_path]["Elements"];
150: for($function_element=0;$function_element<$function_elements;$function_element++)
151: {
152: $function_element_path=$element_path.",$function_element";
153: $data=$code->structure[$function_element_path];
154: if(GetType($data)=="array")
155: {
156: switch($data["Tag"])
157: {
1.12 mlemos 158: case "name":
1.1 mlemos 159: if(IsSet($name))
160: {
1.12 mlemos 161: $compiler->SetElementError($attributes->file,$function_element_path,"it was defined the class function name more than once");
1.1 mlemos 162: return(0);
163: }
1.12 mlemos 164: if(!$compiler->GetValidName($attributes->file,$function_element_path,&$name,"it was not specified a valid class function name option"))
1.1 mlemos 165: return(0);
1.17 mlemos 166: if(IsSet($this->classes[$index]["functions"][$name]))
1.1 mlemos 167: {
1.16 mlemos 168: $compiler->SetElementError($attributes->file,$function_element_path,"it was specified a name of an already defined class function");
1.1 mlemos 169: return(0);
170: }
1.23 mlemos 171: if(IsSet($this->classes[$index]["variables"][$name]))
172: {
173: $compiler->SetElementError($attributes->file,$function_element_path,"it was specified the same name for a class variable and a class function");
174: return(0);
175: }
1.35 mlemos 176: if($index)
1.17 mlemos 177: {
1.35 mlemos 178: for($class_parent=$parent;;$class_parent=$this->classes[$class_parent]["parent"])
179: {
180: if(IsSet($this->classes[$class_parent]["functions"][$name]))
181: {
182: $function["type"]=$this->classes[$class_parent]["functions"][$name]["type"];
183: if(IsSet($this->classes[$class_parent]["functions"][$name]["Arguments"]))
184: $function["Arguments"]=$this->classes[$class_parent]["functions"][$name]["Arguments"];
1.67 mlemos 185: if(IsSet($this->classes[$class_parent]["functions"][$name]["protected"]))
186: $function["protected"]=$this->classes[$class_parent]["functions"][$name]["protected"];
1.35 mlemos 187: break;
188: }
189: if(!IsSet($this->classes[$class_parent]["parent"]))
190: break;
191: }
1.17 mlemos 192: }
1.1 mlemos 193: break;
1.12 mlemos 194: case "type":
1.17 mlemos 195: if(!IsSet($name))
196: {
197: $compiler->SetElementError($attributes->file,$function_element_path,"it was defined the class function return type before specifying its name");
198: return(0);
199: }
200: if($index
201: && IsSet($this->classes[$parent]["functions"][$name]))
202: {
1.23 mlemos 203: $compiler->SetElementError($attributes->file,$function_element_path,"it was attempted to redefine the class return type of a inherited subclass function");
1.17 mlemos 204: return(0);
205: }
1.12 mlemos 206: if(IsSet($function["type"]))
1.1 mlemos 207: {
1.12 mlemos 208: $compiler->SetElementError($attributes->file,$function_element_path,"it was defined the class function type more than once");
1.1 mlemos 209: return(0);
210: }
1.12 mlemos 211: if(!$compiler->GetValidData($attributes->file,$function_element_path,&$function["type"],"it was not specified a valid class function type option"))
1.1 mlemos 212: return(0);
1.12 mlemos 213: switch($function["type"])
1.10 mlemos 214: {
215: case "VOID":
216: case "STRING":
217: case "INTEGER":
1.45 mlemos 218: case "FLOAT":
1.10 mlemos 219: case "BOOLEAN":
220: case "OBJECT":
221: case "ARRAY":
1.53 mlemos 222: case "HASH":
1.10 mlemos 223: break;
224: default:
1.38 mlemos 225: $compiler->SetElementError($attributes->file,$function_element_path,"it was not defined a valid class function return type");
1.10 mlemos 226: return(0);
227: }
228: break;
1.67 mlemos 229: case "protected":
1.52 mlemos 230: if(!IsSet($name))
231: {
1.67 mlemos 232: $compiler->SetElementError($attributes->file,$function_element_path,"it was defined the class function protected status before specifying its name");
1.52 mlemos 233: return(0);
234: }
235: if($index
236: && IsSet($this->classes[$parent]["functions"][$name]))
237: {
1.67 mlemos 238: $compiler->SetElementError($attributes->file,$function_element_path,"it was attempted to redefine the class protected status of a inherited subclass function");
1.52 mlemos 239: return(0);
240: }
1.67 mlemos 241: if(IsSet($function["protected"]))
1.52 mlemos 242: {
1.67 mlemos 243: $compiler->SetElementError($attributes->file,$function_element_path,"it was defined the class function protected status more than once");
1.52 mlemos 244: return(0);
245: }
1.67 mlemos 246: $function["protected"]=1;
1.52 mlemos 247: break;
1.12 mlemos 248: case "argument":
1.17 mlemos 249: if(!IsSet($name))
250: {
251: $compiler->SetElementError($attributes->file,$function_element_path,"it was defined the class function argument before specifying its name");
252: return(0);
253: }
254: if($index
255: && IsSet($this->classes[$parent]["functions"][$name]))
256: {
257: $compiler->SetElementError($attributes->file,$function_element_path,"it was attempted to redefine a class argument of a inherited subclass function");
258: return(0);
259: }
1.10 mlemos 260: Unset($argument_name);
261: $argument=array();
262: $argument_elements=$code->structure[$function_element_path]["Elements"];
263: for($argument_element=0;$argument_element<$argument_elements;$argument_element++)
264: {
265: $argument_element_path=$function_element_path.",$argument_element";
266: $data=$code->structure[$argument_element_path];
267: if(GetType($data)=="array")
268: {
269: switch($data["Tag"])
270: {
1.12 mlemos 271: case "name":
1.10 mlemos 272: if(IsSet($argument_name))
273: {
1.12 mlemos 274: $compiler->SetElementError($attributes->file,$argument_element_path,"it was defined the class function argument name more than once");
1.10 mlemos 275: return(0);
276: }
1.12 mlemos 277: if(!$compiler->GetValidName($attributes->file,$argument_element_path,&$argument_name,"it was not specified a valid class function argument name option"))
1.10 mlemos 278: return(0);
279: if(IsSet($function["Arguments"][$argument_name]))
280: {
1.12 mlemos 281: $compiler->SetElementError($attributes->file,$argument_element_path,"it was specified a name of an already defined class function argument");
1.10 mlemos 282: return(0);
283: }
284: break;
1.12 mlemos 285: case "type":
286: if(IsSet($argument["type"]))
1.10 mlemos 287: {
1.12 mlemos 288: $compiler->SetElementError($attributes->file,$argument_element_path,"it was defined the class function argument type more than once");
1.10 mlemos 289: return(0);
290: }
1.13 mlemos 291: if(!$compiler->GetValidData($attributes->file,$argument_element_path,&$argument["type"],"it was not specified a valid class function type option"))
1.10 mlemos 292: return(0);
1.12 mlemos 293: switch($argument["type"])
1.10 mlemos 294: {
295: case "STRING":
296: case "INTEGER":
1.45 mlemos 297: case "FLOAT":
1.10 mlemos 298: case "BOOLEAN":
299: case "OBJECT":
300: case "ARRAY":
1.53 mlemos 301: case "HASH":
1.10 mlemos 302: break;
303: default:
1.12 mlemos 304: $compiler->SetElementError($attributes->file,$argument_element_path,"it was not defined a valid class function argument type");
1.10 mlemos 305: return(0);
306: }
307: break;
1.51 mlemos 308: case "defaultvalue":
309: if(IsSet($argument["defaultvalue"]))
310: {
311: $compiler->SetElementError($attributes->file,$argument_element_path,"it was defined the class function argument defaultvalue more than once");
312: return(0);
313: }
314: if(IsSet($argument["reference"]))
315: {
316: $compiler->SetElementError($attributes->file,$argument_element_path,"it was defined a defaultvalue for a class function argument to be passed by reference");
317: return(0);
318: }
319: if(!IsSet($argument["type"]))
320: {
321: $compiler->SetElementError($attributes->file,$argument_element_path,"it was not defined the class function argument type before defining the defaultvalue");
322: return(0);
323: }
324: if(!$compiler->GetValidData($attributes->file,$argument_element_path,&$argument["defaultvalue"],"it was not specified a valid class argument defaultvalue option")
325: || !$compiler->ConvertData(&$attributes,$argument["type"],$argument["defaultvalue"],&$argument["converteddefaultvalue"]))
326: return(0);
327: break;
1.23 mlemos 328: case "reference":
329: if(IsSet($argument["reference"]))
330: {
331: $compiler->SetElementError($attributes->file,$argument_element_path,"it was defined the class function argument reference more than once");
332: return(0);
333: }
1.51 mlemos 334: if(IsSet($argument["defaultvalue"]))
335: {
336: $compiler->SetElementError($attributes->file,$argument_element_path,"it was defined a defaultvalue for a class function argument to be passed by reference");
337: return(0);
338: }
1.23 mlemos 339: $argument["reference"]=1;
340: break;
1.42 mlemos 341: case "documentation":
1.44 mlemos 342: if(!$this->GetDocumentation(&$argument,&$compiler,&$code,&$attributes,$argument_element_path))
343: return(0);
1.42 mlemos 344: break;
1.10 mlemos 345: default:
1.23 mlemos 346: $compiler->SetElementError($attributes->file,$argument_element_path,$data["Tag"]." is not a supported class function argument attribute");
1.10 mlemos 347: return(0);
348: }
349: }
350: else
351: {
352: if(!$compiler->CheckWhiteSpace($attributes->file,$data,$argument_element_path))
353: return(0);
354: }
355: }
356: if(!IsSet($argument_name))
357: {
1.12 mlemos 358: $compiler->SetElementError($attributes->file,$function_element_path,"it was not defined the class function argument name");
1.10 mlemos 359: return(0);
360: }
1.12 mlemos 361: if(!IsSet($argument["type"]))
1.10 mlemos 362: {
1.12 mlemos 363: $compiler->SetElementError($attributes->file,$function_element_path,"it was not defined the class function argument type");
1.10 mlemos 364: return(0);
365: }
366: $function["Arguments"][$argument_name]=$argument;
1.1 mlemos 367: break;
1.12 mlemos 368: case "do":
369: if(IsSet($function["do"]))
1.1 mlemos 370: {
1.12 mlemos 371: $compiler->SetElementError($attributes->file,$function_element_path,"it was defined the class function do statements more than once");
1.1 mlemos 372: return(0);
373: }
1.12 mlemos 374: $function["do"]=array(
1.1 mlemos 375: "file"=>$attributes->file,
376: "path"=>$function_element_path
377: );
1.18 mlemos 378: $this->classes[$index]["functions"][$name]=$function;
1.1 mlemos 379: break;
1.42 mlemos 380: case "documentation":
1.44 mlemos 381: if(!$this->GetDocumentation(&$function,&$compiler,&$code,&$attributes,$function_element_path))
382: return(0);
1.42 mlemos 383: break;
1.1 mlemos 384: default:
1.12 mlemos 385: $compiler->SetElementError($attributes->file,$function_element_path,$data["Tag"]." is not a supported class object attribute");
1.1 mlemos 386: return(0);
387: }
388: }
389: else
390: {
391: if(!$compiler->CheckWhiteSpace($attributes->file,$data,$function_element_path))
392: return(0);
393: }
394: }
395: if(!IsSet($name))
396: {
1.36 mlemos 397: $compiler->SetElementError($attributes->file,$element_path,"it was not defined the class function name");
1.1 mlemos 398: return(0);
399: }
1.12 mlemos 400: if(!IsSet($function["type"]))
1.1 mlemos 401: {
1.36 mlemos 402: $compiler->SetElementError($attributes->file,$element_path,"it was not defined the class function return type");
1.1 mlemos 403: return(0);
404: }
1.12 mlemos 405: if(!IsSet($function["do"]))
1.1 mlemos 406: {
1.36 mlemos 407: $compiler->SetElementError($attributes->file,$element_path,"it was not defined the class function do statmemnts");
1.1 mlemos 408: return(0);
409: }
410: break;
1.12 mlemos 411: case "variable":
1.17 mlemos 412: if(count($this->classes[$index]["functions"]))
413: {
414: $compiler->SetElementError($attributes->file,$element_path,"it was attempted to define a class variable after having declared class functions");
415: return(0);
416: }
1.6 mlemos 417: Unset($name);
418: $variable=array();
419: $variable_elements=$code->structure[$element_path]["Elements"];
420: for($variable_element=0;$variable_element<$variable_elements;$variable_element++)
421: {
422: $variable_element_path=$element_path.",$variable_element";
423: $data=$code->structure[$variable_element_path];
424: if(GetType($data)=="array")
425: {
426: switch($data["Tag"])
427: {
1.12 mlemos 428: case "name":
1.6 mlemos 429: if(IsSet($name))
430: {
1.12 mlemos 431: $compiler->SetElementError($attributes->file,$variable_element_path,"it was defined the class variable name more than once");
1.6 mlemos 432: return(0);
433: }
1.12 mlemos 434: if(!$compiler->GetValidName($attributes->file,$variable_element_path,&$name,"it was not specified a valid class variable name option"))
1.6 mlemos 435: return(0);
1.17 mlemos 436: if(IsSet($this->classes[$index]["variables"][$name]))
1.6 mlemos 437: {
1.12 mlemos 438: $compiler->SetElementError($attributes->file,$variable_element_path,"it was specified a name of an already defined class variable");
1.6 mlemos 439: return(0);
440: }
1.17 mlemos 441: if($index
442: && IsSet($this->classes[$parent]["variables"][$name]))
1.57 mlemos 443: {
1.17 mlemos 444: $variable["type"]=$this->classes[$parent]["variables"][$name]["type"];
1.67 mlemos 445: if(IsSet($this->classes[$parent]["variables"][$name]["protected"]))
446: $variable["protected"]=$this->classes[$parent]["variables"][$name]["protected"];
1.57 mlemos 447: }
1.6 mlemos 448: break;
1.12 mlemos 449: case "type":
1.17 mlemos 450: if(!IsSet($name))
451: {
1.29 mlemos 452: $compiler->SetElementError($attributes->file,$variable_element_path,"it was defined the class variable type before specifying its name");
1.17 mlemos 453: return(0);
454: }
1.37 mlemos 455: $class=$parent;
456: if($this->InheritedVariableClass(&$class,$name))
1.17 mlemos 457: {
1.36 mlemos 458: $compiler->SetElementError($attributes->file,$variable_element_path,"it was attempted to redefine the type of a inherited subclass variable");
1.17 mlemos 459: return(0);
460: }
1.12 mlemos 461: if(IsSet($variable["type"]))
1.6 mlemos 462: {
1.12 mlemos 463: $compiler->SetElementError($attributes->file,$variable_element_path,"it was defined the class variable type more than once");
1.6 mlemos 464: return(0);
465: }
1.12 mlemos 466: if(!$compiler->GetValidData($attributes->file,$variable_element_path,&$variable["type"],"it was not specified a valid class variable type option"))
1.6 mlemos 467: return(0);
1.17 mlemos 468: switch($variable["type"])
469: {
470: case "STRING":
471: case "INTEGER":
1.45 mlemos 472: case "FLOAT":
1.17 mlemos 473: case "BOOLEAN":
474: case "OBJECT":
475: case "ARRAY":
1.53 mlemos 476: case "HASH":
1.17 mlemos 477: break;
478: default:
479: $compiler->SetElementError($attributes->file,$variable_element_path,"it was not defined a valid class variable type");
480: return(0);
481: }
1.6 mlemos 482: break;
1.67 mlemos 483: case "protected":
1.52 mlemos 484: if(!IsSet($name))
485: {
1.67 mlemos 486: $compiler->SetElementError($attributes->file,$variable_element_path,"it was defined the class variable protected status before specifying its name");
1.52 mlemos 487: return(0);
488: }
489: $class=$parent;
490: if($this->InheritedVariableClass(&$class,$name))
491: {
1.67 mlemos 492: $compiler->SetElementError($attributes->file,$variable_element_path,"it was attempted to redefine the protected status of a inherited subclass variable");
1.52 mlemos 493: return(0);
494: }
1.67 mlemos 495: if(IsSet($variable["protected"]))
1.52 mlemos 496: {
1.67 mlemos 497: $compiler->SetElementError($attributes->file,$variable_element_path,"it was defined the class variable protected status more than once");
1.52 mlemos 498: return(0);
499: }
1.67 mlemos 500: $variable["protected"]=1;
1.52 mlemos 501: break;
1.12 mlemos 502: case "value":
1.37 mlemos 503: $class=$parent;
504: if($this->InheritedVariableClass(&$class,$name))
505: $type=$this->classes[$class]["variables"][$name]["type"];
506: else
1.17 mlemos 507: {
1.37 mlemos 508: if(!IsSet($variable["type"]))
509: {
510: $compiler->SetElementError($attributes->file,$variable_element_path,"it was defined a class variable value before specifying the variable type");
511: return(0);
512: }
513: $type=$variable["type"];
1.17 mlemos 514: }
1.12 mlemos 515: if(IsSet($variable["value"]))
1.8 mlemos 516: {
1.12 mlemos 517: $compiler->SetElementError($attributes->file,$variable_element_path,"it was defined the class variable initial value more than once");
1.8 mlemos 518: return(0);
519: }
1.17 mlemos 520: if(!$compiler->GetValidData($attributes->file,$variable_element_path,&$variable["value"],"it was not specified a valid class variable value option")
1.44 mlemos 521: || !$compiler->ConvertData(&$attributes,$type,$variable["value"],&$variable["convertedvalue"]))
1.8 mlemos 522: return(0);
523: break;
1.42 mlemos 524: case "documentation";
1.44 mlemos 525: if(!$this->GetDocumentation(&$variable,&$compiler,&$code,&$attributes,$variable_element_path))
526: return(0);
1.42 mlemos 527: break;
1.6 mlemos 528: default:
1.12 mlemos 529: $compiler->SetElementError($attributes->file,$variable_element_path,$data["Tag"]." is not a supported class object variable attribute");
1.6 mlemos 530: return(0);
531: }
532: }
533: else
534: {
535: if(!$compiler->CheckWhiteSpace($attributes->file,$data,$variable_element_path))
536: return(0);
537: }
538: }
539: if(!IsSet($name))
540: {
1.38 mlemos 541: $compiler->SetElementError($attributes->file,$element_path,"it was not defined the class variable name");
1.6 mlemos 542: return(0);
543: }
1.37 mlemos 544: $class=$parent;
545: if(!$this->InheritedVariableClass(&$class,$name)
546: && !IsSet($variable["type"]))
1.6 mlemos 547: {
1.38 mlemos 548: $compiler->SetElementError($attributes->file,$element_path,"it was not defined the class variable type");
1.6 mlemos 549: return(0);
550: }
1.17 mlemos 551: $this->classes[$index]["variables"][$name]=$variable;
1.16 mlemos 552: break;
1.56 mlemos 553: case "abstract":
554: $this->classes[$index][$data["Tag"]]=1;
555: break;
1.16 mlemos 556: case "file":
557: case "basepath":
1.30 mlemos 558: case "tag":
1.64 mlemos 559: case "version":
1.52 mlemos 560: case "copyright":
1.42 mlemos 561: case "title":
562: case "author":
563: case "authoraddress":
1.30 mlemos 564: if(!$compiler->GetValidData($attributes->file,$element_path,&$this->classes[$index][$data["Tag"]],"it was not specified a valid class ".$data["Tag"]." property"))
1.13 mlemos 565: return(0);
566: break;
1.42 mlemos 567: case "documentation":
1.44 mlemos 568: if(!$this->GetDocumentation(&$this->classes[$index],&$compiler,&$code,&$attributes,$element_path))
1.42 mlemos 569: return(0);
570: break;
1.16 mlemos 571: default:
572: $compiler->SetElementError($attributes->file,$element_path,$data["Tag"]." is not a supported class object class attribute");
573: return(0);
574: }
575: }
576: else
577: {
578: if(!$compiler->CheckWhiteSpace($attributes->file,$data,$element_path))
579: return(0);
580: }
581: }
1.17 mlemos 582: if(!IsSet($this->classes[$index]["name"]))
583: {
584: if($index)
585: {
586: $compiler->SetElementError($attributes->file,$attributes->path,"it was not specified the class name");
587: return(0);
588: }
589: else
590: {
591: $this->classes[$index]["name"]=$this->object_name;
592: $this->subclasses[$this->object_name]=$index;
593: }
594: }
595: if($index)
1.56 mlemos 596: {
597: if(IsSet($this->classes[$index]["abstract"])
598: && !IsSet($this->classes[$parent]["abstract"]))
599: {
600: $compiler->SetElementError($attributes->file,$attributes->path,"it was defined the abstract attribute for a subclass of a class that is not abstract");
601: return(0);
602: }
1.18 mlemos 603: $this->classes[$index]["parent"]=$parent;
1.56 mlemos 604: }
1.30 mlemos 605: if(!IsSet($this->classes[$index]["tag"]))
606: $this->classes[$index]["tag"]="CLASS_".strtoupper(ereg_replace("[^A-Za-z0-9]","_",$this->classes[$index]["file"]));
1.16 mlemos 607: return(1);
608: }
609:
610: Function Setup(&$compiler,&$code,&$attributes)
611: {
612: $elements=$code->structure[$attributes->path]["Elements"];
613: for($element=0;$element<$elements;$element++)
614: {
615: $element_path=$attributes->path.",$element";
616: $data=$code->structure[$element_path];
617: if(GetType($data)=="array")
618: {
619: switch($data["Tag"])
620: {
621: case "class":
1.17 mlemos 622: if(count($this->classes))
1.16 mlemos 623: {
624: $compiler->SetElementError($attributes->file,$element_path,"it was attempted to redefine the base class");
625: return(0);
626: }
627: $class_attributes=$attributes;
628: $class_attributes->path=$element_path;
1.17 mlemos 629: if(!$this->SetupClass(&$compiler,&$code,&$class_attributes))
1.13 mlemos 630: return(0);
631: break;
1.1 mlemos 632: default:
1.12 mlemos 633: $compiler->SetElementError($attributes->file,$element_path,$data["Tag"]." is not a supported class object attribute");
1.1 mlemos 634: return(0);
635: }
636: }
637: else
638: {
639: if(!$compiler->CheckWhiteSpace($attributes->file,$data,$element_path))
640: return(0);
641: }
642: }
643: return(1);
644: }
645:
1.55 mlemos 646: Function GenerateFunction(&$compiler,$class,$name)
647: {
648: if(!IsSet($this->classes[$class]["functions"][$name]["do"]["code"]))
649: {
650: $this->classes[$class]["functions"][$name]["do"]["code"]=array();
651: $function_name=$this->classes[$class]["function_name"];
652: $return_type=$this->classes[$class]["return_type"];
653: $return_value_set=$this->classes[$class]["return_value_set"];
654: $this->classes[$class]["function_name"]=$name;
655: $this->classes[$class]["return_type"]=$this->classes[$class]["functions"][$name]["type"];
656: $this->classes[$class]["return_value_set"]=0;
657: $action_context=new metal_execution_context_class;
658: $action_context->file=$this->classes[$class]["functions"][$name]["do"]["file"];
659: $action_context->path=$this->classes[$class]["functions"][$name]["do"]["path"];
660: $action_context->result=array();
661: $functions=array(
662: "instancevariable",
663: "instancecall",
664: "functionargument",
665: "return"
666: );
1.71 ! mlemos 667: if(!$compiler->AddContextFunctions(&$action_context,$this->object_name,&$functions,&$level)
! 668: || !$compiler->StartScope(&$action_context,&$scope,"method"))
1.55 mlemos 669: return(0);
1.71 ! mlemos 670: $current_subclass=$this->current_subclass;
1.55 mlemos 671: $this->current_subclass=$class;
672: if(!$compiler->GetOutputData($this->classes[$class]["functions"][$name]["do"]["file"],$this->classes[$class]["functions"][$name]["do"]["path"],&$this->classes[$class]["functions"][$name]["do"]["code"],"it were not defined valid class function do statements",1))
673: return(0);
1.71 ! mlemos 674: $this->current_subclass=$current_subclass;
! 675: $success=$compiler->EndScope(&$context,$scope);
! 676: if(!$compiler->RemoveContextFunctions(&$action_context,$this->object_name,$level)
! 677: || !$success)
1.55 mlemos 678: return(0);
679: if(strcmp($this->classes[$class]["functions"][$name]["type"],"VOID")
680: && $this->classes[$class]["return_value_set"]==0)
681: {
682: $compiler->SetElementError($this->classes[$class]["functions"][$name]["do"]["file"],$this->classes[$class]["functions"][$name]["do"]["path"],"it was not set the class function return value");
683: return(0);
684: }
685: $this->classes[$class]["function_name"]=$function_name;
686: $this->classes[$class]["return_type"]=$return_type;
687: $this->classes[$class]["return_value_set"]=$return_value_set;
688: }
689: return(1);
690: }
691:
1.18 mlemos 692: Function InheritedFunctionClass(&$class,$function)
693: {
694: for(;;$class=$this->classes[$class]["parent"])
695: {
696: if(IsSet($this->classes[$class]["functions"][$function]))
697: return(1);
698: if($class==0)
699: return(0);
700: }
701: }
702:
703: Function InheritedVariableClass(&$class,$variable)
704: {
705: for(;;$class=$this->classes[$class]["parent"])
706: {
707: if(IsSet($this->classes[$class]["variables"][$variable]))
708: return(1);
709: if($class==0)
710: return(0);
711: }
712: }
713:
1.10 mlemos 714: Function Call(&$compiler,&$code,&$context,&$call,$function)
1.1 mlemos 715: {
1.50 mlemos 716: $class=$subclass=(IsSet($call["subclass"]) ? $call["subclass"] : $this->current_subclass);
1.1 mlemos 717: $elements=$code->structure[$context->path]["Elements"];
718: for($element=0;$element<$elements;$element++)
719: {
720: $element_path=$context->path.",$element";
721: $data=$code->structure[$element_path];
722: if(GetType($data)=="array")
723: {
724: switch($data["Tag"])
725: {
1.17 mlemos 726: case "subclass":
727: if(count($call))
728: {
729: $compiler->SetElementError($context->file,$element_path,"it was specified the class $function subclass argument after having specified other arguments");
730: return(0);
731: }
1.18 mlemos 732: if(!$this->GetSubclassArgument(&$compiler,$context->file,$element_path,&$call))
733: return(0);
1.17 mlemos 734: $subclass=$call["subclass"];
735: break;
1.12 mlemos 736: case "function":
1.1 mlemos 737: $argument=$data["Tag"];
738: if(IsSet($call[$argument]))
739: {
1.14 mlemos 740: $compiler->SetElementError($context->file,$element_path,"it was specified the class $function $argument argument more than once");
1.10 mlemos 741: return(0);
742: }
1.12 mlemos 743: if(!$compiler->GetValidData($context->file,$element_path,&$call["function"],"it was not specified a valid class $function function argument"))
1.10 mlemos 744: return(0);
1.18 mlemos 745: $class=$subclass;
746: if(!$this->InheritedFunctionClass(&$class,$call["function"]))
1.10 mlemos 747: {
1.26 mlemos 748: $compiler->SetElementError($context->file,$element_path,"it was requested to $function a class function (\"".$call["function"]."\") that was not defined");
1.10 mlemos 749: return(0);
750: }
751: break;
1.12 mlemos 752: case "arguments":
753: if(!IsSet($call["function"]))
1.10 mlemos 754: {
1.12 mlemos 755: $compiler->SetElementError($context->file,$element_path,"it was not defined the function to call before specifying the $function arguments");
1.1 mlemos 756: return(0);
757: }
1.18 mlemos 758: if(!IsSet($this->classes[$class]["functions"][$call["function"]]["Arguments"]))
1.1 mlemos 759: {
1.12 mlemos 760: $compiler->SetElementError($context->file,$element_path,"the specified function to $function does not take any arguments");
1.10 mlemos 761: return(0);
762: }
1.18 mlemos 763: $function_arguments=$this->classes[$class]["functions"][$call["function"]]["Arguments"];
1.10 mlemos 764: $argument_elements=$code->structure[$element_path]["Elements"];
765: for($argument_element=0;$argument_element<$argument_elements;$argument_element++)
766: {
767: $argument_element_path=$element_path.",$argument_element";
768: $data=$code->structure[$argument_element_path];
769: if(GetType($data)=="array")
770: {
771: if(!IsSet($function_arguments[$data["Tag"]]))
772: {
1.12 mlemos 773: $compiler->SetElementError($context->file,$argument_element_path,"it was not specified a valid $function function argument");
1.1 mlemos 774: return(0);
1.10 mlemos 775: }
1.12 mlemos 776: if(IsSet($call["arguments"][$data["Tag"]]))
1.1 mlemos 777: {
1.12 mlemos 778: $compiler->SetElementError($context->file,$argument_element_path,"it was specified the ".$data["Tag"]." $function function argument more than once");
1.1 mlemos 779: return(0);
780: }
1.12 mlemos 781: $call["arguments"][$data["Tag"]]=array(
1.10 mlemos 782: "file"=>$context->file,
783: "path"=>$argument_element_path,
1.12 mlemos 784: "type"=>$function_arguments[$data["Tag"]]["type"]
1.10 mlemos 785: );
786: }
787: else
788: {
789: if(!$compiler->CheckWhiteSpace($context->file,$data,$argument_element_path))
1.1 mlemos 790: return(0);
1.10 mlemos 791: }
1.1 mlemos 792: }
793: break;
1.19 mlemos 794: case "object":
795: if(strcmp($function,"instancecall"))
796: {
797: $argument=$data["Tag"];
798: if(IsSet($call[$argument]))
799: {
800: $compiler->SetElementError($context->file,$element_path,"it was specified the class $function $argument argument more than once");
801: return(0);
802: }
803: $evaluate_context=$context;
804: $evaluate_context->path=$element_path;
805: if(!$compiler->GetValidExpression(&$evaluate_context,"OBJECT","NOTRIGHT","it was not specified a valid class object expression",1)
806: || !$compiler->GetExpressionValue(&$context,&$evaluate_context->result,&$call["object"],&$expression_type))
807: return(0);
808: break;
809: }
1.1 mlemos 810: default:
1.12 mlemos 811: $compiler->SetElementError($context->file,$element_path,$data["Tag"]." is not a supported class $function argument");
1.1 mlemos 812: return(0);
813: }
814: }
815: else
816: {
817: if(!$compiler->CheckWhiteSpace($context->file,$data,$element_path))
818: return(0);
819: }
820: }
821: return(1);
822: }
823:
1.17 mlemos 824: Function GetSubclassArgument(&$compiler,$file,$path,&$values)
825: {
826: if(IsSet($value["subclass"]))
827: {
828: $compiler->SetElementError($file,$path,"it was specified the class object subclass argument more than once");
829: return(0);
830: }
831: if(!$compiler->GetValidData($file,$path,&$subclass,"it was not specified a valid class subclass argument"))
832: return(0);
833: if(!IsSet($this->subclasses[$subclass]))
834: {
835: $compiler->SetElementError($file,$path,"it was not specified a defined subclass (\"$subclass\")");
836: return(0);
837: }
838: $values["subclass"]=$this->subclasses[$subclass];
839: return(1);
840: }
841:
1.42 mlemos 842: Function GetClassScope(&$compiler,&$arguments_code,&$arguments,&$class,$allow_tags,&$tags)
1.17 mlemos 843: {
844: $output=array();
845: $elements=$arguments_code->structure[$arguments->path]["Elements"];
846: for($element=0;$element<$elements;$element++)
847: {
848: $element_path=$arguments->path.",$element";
849: $data=$arguments_code->structure[$element_path];
850: if(GetType($data)=="array")
851: {
852: switch($data["Tag"])
853: {
854: case "subclass":
855: if(!$this->GetSubclassArgument(&$compiler,$arguments->file,$element_path,&$output))
856: return(0);
857: break;
858: default:
1.42 mlemos 859: if(!$allow_tags)
860: {
861: $compiler->SetElementError($arguments->file,$element_path,$data["Tag"]." is not a supported class object scope tag");
862: return(0);
863: }
1.52 mlemos 864: if(IsSet($tags[$data["Tag"]]))
1.42 mlemos 865: {
866: $compiler->SetElementError($arguments->file,$element_path,"it was specified the class scope tag ".$data["Tag"]." more than once");
867: return(0);
868: }
869: $compiler->CopyEmptyContext(&$arguments,&$tags[$data["Tag"]]);
870: $tags[$data["Tag"]]->path=$element_path;
871: break;
1.17 mlemos 872: }
873: }
874: else
875: {
876: if(!$compiler->CheckWhiteSpace($arguments->file,$data,$element_path))
877: return(0);
878: }
879: }
1.49 mlemos 880: $class=(IsSet($output["subclass"]) ? $output["subclass"] : $this->current_subclass);
1.17 mlemos 881: return(1);
882: }
883:
1.67 mlemos 884: Function IterateVariables(&$compiler,&$context,$class,&$variables,$protected,$public,$inherited)
1.59 mlemos 885: {
886: for($class_variable=0,Reset($this->classes[$class]["variables"]);$class_variable<count($this->classes[$class]["variables"]);Next($this->classes[$class]["variables"]),$class_variable++)
887: {
888: $this->current_class=$class;
889: $this->current_variable=Key($this->classes[$class]["variables"]);
890: if(!IsSet($variables[$this->current_variable])
891: && (($public
1.67 mlemos 892: && !IsSet($this->classes[$class]["variables"][$this->current_variable]["protected"]))
893: || ($protected
894: && IsSet($this->classes[$class]["variables"][$this->current_variable]["protected"]))))
1.59 mlemos 895: {
896: if(!$compiler->GetOutputData($context->file,$context->path,&$context->result,"it was not defined valid action for the class variables",1))
897: return(0);
898: $variables[$this->current_variable]=$class;
899: }
900: }
901: if($inherited
902: && IsSet($this->classes[$class]["parent"]))
1.67 mlemos 903: return($this->IterateVariables($compiler,$context,$this->classes[$class]["parent"],&$variables,$protected,$public,$inherited));
1.59 mlemos 904: return(1);
905: }
906:
1.67 mlemos 907: Function IterateFunctions(&$compiler,&$context,$class,&$functions,$protected,$public,$inherited)
1.59 mlemos 908: {
909: for($class_function=0,Reset($this->classes[$class]["functions"]);$class_function<count($this->classes[$class]["functions"]);Next($this->classes[$class]["functions"]),$class_function++)
910: {
911: $this->current_class=$class;
912: $this->current_function=Key($this->classes[$class]["functions"]);
913: if(!IsSet($functions[$this->current_function])
914: && (($public
1.67 mlemos 915: && !IsSet($this->classes[$class]["functions"][$this->current_function]["protected"]))
916: || ($protected
917: && IsSet($this->classes[$class]["functions"][$this->current_function]["protected"]))))
1.59 mlemos 918: {
919: if(!$compiler->GetOutputData($context->file,$context->path,&$context->result,"it was not defined valid action for the class functions",1))
920: return(0);
921: $functions[$this->current_function]=$class;
922: }
923: }
924: if($inherited
925: && IsSet($this->classes[$class]["parent"]))
1.67 mlemos 926: return($this->IterateFunctions($compiler,$context,$this->classes[$class]["parent"],&$functions,$protected,$public,$inherited));
1.59 mlemos 927: return(1);
928: }
929:
1.1 mlemos 930: Function Execute(&$compiler,&$code,$function,&$context,&$arguments_code,&$arguments)
931: {
1.54 mlemos 932: switch($compiler->language["name"])
1.1 mlemos 933: {
1.54 mlemos 934: case "Java":
935: switch($function)
936: {
937: case "output":
1.68 mlemos 938: case "functionargument":
1.69 mlemos 939: case "return":
940: case "instancevariable":
1.70 mlemos 941: case "instancecall":
942: case "call":
1.54 mlemos 943: break;
944: default:
945: $compiler->SetElementError($context->file,$context->path,"$function function of the class class is not implemented for the language ".$compiler->language["name"]);
946: return(0);
947: }
948: break;
949: case "PHP":
950: break;
951: default:
952: $compiler->SetElementError($context->file,$context->path,$compiler->language["name"]." is not a language supported by the class class");
953: return(0);
1.1 mlemos 954: }
955: switch($function)
956: {
1.15 mlemos 957: case "load":
958: $load=array();
959: $elements=$arguments_code->structure[$arguments->path]["Elements"];
960: for($element=0;$element<$elements;$element++)
961: {
962: $element_path=$arguments->path.",$element";
963: $data=$arguments_code->structure[$element_path];
964: if(GetType($data)=="array")
965: {
966: switch($data["Tag"])
967: {
1.17 mlemos 968: case "subclass":
1.18 mlemos 969: if(!$this->GetSubclassArgument(&$compiler,$arguments->file,$element_path,&$load))
970: return(0);
1.17 mlemos 971: break;
1.15 mlemos 972: case "classpointer":
973: case "error":
974: if(IsSet($load[$data["Tag"]]))
975: {
976: $compiler->SetElementError($arguments->file,$element_path,"it was specified the class load ".$data["Tag"]." argument more than once");
977: return(0);
978: }
979: $evaluate_context=$arguments;
980: $evaluate_context->path=$element_path;
981: if(!$compiler->GetValidExpression(&$evaluate_context,"STRING","NOTRIGHT","it was not specified a valid class load ".$data["Tag"]." variable",1)
982: || !$compiler->GetExpressionValue(&$context,&$evaluate_context->result,&$load[$data["Tag"]],&$expression_type))
983: return(0);
984: break;
985: default:
986: $compiler->SetElementError($arguments->file,$element_path,$data["Tag"]." is not a supported class load argument");
987: return(0);
988: }
989: }
990: else
991: {
992: if(!$compiler->CheckWhiteSpace($arguments->file,$data,$element_path))
993: return(0);
994: }
995: }
1.17 mlemos 996: $subclass=(IsSet($load["subclass"]) ? $load["subclass"] : 0);
1.56 mlemos 997: if(IsSet($this->classes[$subclass]["abstract"]))
998: {
999: $compiler->SetElementError($context->file,$context->path,"an abstract class can not be loaded");
1000: return(0);
1001: }
1.17 mlemos 1002: $relative_path=$compiler->RelativePath($this->classes[$subclass]["basepath"],$this->classes[$subclass]["file"]);
1.15 mlemos 1003: $context->result[]=array(
1004: "Data"=>array(
1.17 mlemos 1005: "Name"=>$this->classes[$subclass]["file"],
1.15 mlemos 1006: "Type"=>"SUPPLIED"
1007: ),
1008: "Type"=>"FILE"
1009: );
1.20 mlemos 1010: $context->result[]=array(
1.30 mlemos 1011: "Data"=>"if(!defined(\"".$this->classes[0]["tag"]."\")",
1.20 mlemos 1012: "Type"=>"COMMAND"
1013: );
1014: $context->result[]=array(
1015: "Data"=>"&& file_exists(\"$relative_path\"))",
1016: "Type"=>"COMMAND"
1017: );
1018: $context->result[]=array(
1019: "Data"=>"{",
1020: "Type"=>"COMMAND"
1021: );
1022: $context->result[]=array(
1023: "Data"=>1,
1024: "Type"=>"INDENT"
1025: );
1026: $context->result[]=array(
1027: "Data"=>"include(\"$relative_path\");",
1028: "Type"=>"COMMAND"
1029: );
1.15 mlemos 1030: if(IsSet($load["error"]))
1031: {
1032: $context->result[]=array(
1.20 mlemos 1033: "Data"=>$load["error"]."=\"\";",
1.15 mlemos 1034: "Type"=>"COMMAND"
1035: );
1036: }
1037: $context->result[]=array(
1038: "Data"=>1,
1.20 mlemos 1039: "Type"=>"OUTDENT"
1.15 mlemos 1040: );
1041: $context->result[]=array(
1.20 mlemos 1042: "Data"=>"}",
1.15 mlemos 1043: "Type"=>"COMMAND"
1044: );
1.20 mlemos 1045: if(IsSet($load["error"]))
1046: {
1047: $context->result[]=array(
1048: "Data"=>"else",
1049: "Type"=>"COMMAND"
1050: );
1051: $context->result[]=array(
1052: "Data"=>1,
1053: "Type"=>"INDENT"
1054: );
1055: $context->result[]=array(
1056: "Data"=>$load["error"]."=\"could not access the class code file \\\"$relative_path\\\"\";",
1057: "Type"=>"COMMAND"
1058: );
1059: $context->result[]=array(
1060: "Data"=>1,
1061: "Type"=>"OUTDENT"
1062: );
1063: }
1.15 mlemos 1064: if(IsSet($load["classpointer"]))
1065: {
1066: $context->result[]=array(
1.17 mlemos 1067: "Data"=>$load["classpointer"]."=\"".$this->classes[$subclass]["name"]."\";",
1.15 mlemos 1068: "Type"=>"COMMAND"
1069: );
1070: }
1071: break;
1.12 mlemos 1072: case "new":
1.15 mlemos 1073: $new=array();
1074: $elements=$arguments_code->structure[$arguments->path]["Elements"];
1075: for($element=0;$element<$elements;$element++)
1076: {
1077: $element_path=$arguments->path.",$element";
1078: $data=$arguments_code->structure[$element_path];
1079: if(GetType($data)=="array")
1080: {
1081: switch($data["Tag"])
1082: {
1.17 mlemos 1083: case "subclass":
1.18 mlemos 1084: if(!$this->GetSubclassArgument(&$compiler,$arguments->file,$element_path,&$new))
1085: return(0);
1.17 mlemos 1086: break;
1.15 mlemos 1087: case "classpointer":
1088: if(IsSet($new[$data["Tag"]]))
1089: {
1090: $compiler->SetElementError($arguments->file,$element_path,"it was specified the class new ".$data["Tag"]." argument more than once");
1091: return(0);
1092: }
1093: $evaluate_context=$arguments;
1094: $evaluate_context->path=$element_path;
1095: if(!$compiler->GetValidExpression(&$evaluate_context,"STRING","NOTLEFT","it was not specified a valid class new ".$data["Tag"]." argument",1)
1096: || !$compiler->GetExpressionValue(&$context,&$evaluate_context->result,&$new[$data["Tag"]],&$expression_type))
1097: return(0);
1098: break;
1099: default:
1100: $compiler->SetElementError($arguments->file,$element_path,$data["Tag"]." is not a supported class new argument");
1101: return(0);
1102: }
1103: }
1104: else
1105: {
1106: if(!$compiler->CheckWhiteSpace($arguments->file,$data,$element_path))
1107: return(0);
1108: }
1109: }
1.17 mlemos 1110: $subclass=(IsSet($new["subclass"]) ? $new["subclass"] : 0);
1.56 mlemos 1111: if(IsSet($this->classes[$subclass]["abstract"]))
1112: {
1113: $compiler->SetElementError($context->file,$context->path,"an abstract class can not be instanciated");
1114: return(0);
1115: }
1.1 mlemos 1116: $context->result[]=array(
1.34 mlemos 1117: "Data"=>array(
1118: "Object"=>$this->object_name,
1119: "Context"=>$this->classes[$subclass]["name"]
1120: ),
1.1 mlemos 1121: "Type"=>"INITIALIZATION"
1122: );
1.15 mlemos 1123: if(IsSet($new["classpointer"]))
1124: $class_name=$new["classpointer"];
1125: else
1126: {
1.17 mlemos 1127: $class_name=$this->classes[$subclass]["name"];
1.20 mlemos 1128: for($class=$subclass;;$class=$this->classes[$class]["parent"])
1129: {
1130: $this->classes[$class]["staticload"]=1;
1131: if(!$class)
1132: break;
1133: }
1.15 mlemos 1134: }
1.1 mlemos 1135: $context->result[]=array(
1136: "Data"=>array(
1.20 mlemos 1137: "Value"=>"new $class_name",
1.1 mlemos 1138: "Type"=>"OBJECT",
1.17 mlemos 1139: "Class"=>$this->classes[$subclass]["name"],
1.1 mlemos 1140: "Side"=>"RIGHT"
1141: ),
1142: "Type"=>"EXPRESSION"
1143: );
1144: break;
1.12 mlemos 1145: case "instancecall":
1146: case "call":
1.70 mlemos 1147: $message=array();
1148: if(!$this->Call(&$compiler,&$arguments_code,&$arguments,&$message,$function)
1149: || !$this->Call(&$compiler,&$code,&$context,&$message,$function))
1.1 mlemos 1150: return(0);
1.12 mlemos 1151: if((strcmp($function,"instancecall")
1.70 mlemos 1152: && !IsSet($message[$argument="object"]))
1153: || !IsSet($message[$argument="function"]))
1.1 mlemos 1154: {
1.12 mlemos 1155: $compiler->SetElementError($context->file,$context->path,"it was not defined the class $function $argument argument");
1.1 mlemos 1156: return(0);
1157: }
1.70 mlemos 1158: $message["class"]=$subclass=(IsSet($message["subclass"]) ? $message["subclass"] : $this->current_subclass);
1.58 mlemos 1159: if(IsSet($this->classes[$subclass]["abstract"])
1160: && !strcmp($function,"call"))
1.56 mlemos 1161: {
1162: $compiler->SetElementError($context->file,$context->path,"an abstract class can not be called");
1163: return(0);
1164: }
1.70 mlemos 1165: $this->InheritedFunctionClass(&$message["class"],$message["function"]);
1166: $message["argumentlist"]=array();
1167: if(IsSet($this->classes[$message["class"]]["functions"][$message["function"]]["Arguments"]))
1.10 mlemos 1168: {
1.70 mlemos 1169: $arguments=$this->classes[$message["class"]]["functions"][$message["function"]]["Arguments"];
1.10 mlemos 1170: for(Reset($arguments),$argument=0;$argument<count($arguments);Next($arguments),$argument++)
1171: {
1.51 mlemos 1172: $argument_name=Key($arguments);
1.70 mlemos 1173: if(IsSet($message["arguments"][$argument_name]))
1.51 mlemos 1174: {
1.70 mlemos 1175: $argument_context=$message["arguments"][$argument_name];
1.51 mlemos 1176: $evaluate_context=$context;
1177: $evaluate_context->file=$argument_context["file"];
1178: $evaluate_context->path=$argument_context["path"];
1179: $reference=IsSet($argument_context["reference"]);
1180: if(!$compiler->GetValidExpression(&$evaluate_context,$argument_context["type"],$reference ? "BOTH" : "NOTLEFT","it was not specified a valid class function $function argument ".$argument_context["type"]." ".($reference ? "reference" : "value")." expression",0)
1181: || !$compiler->GetExpressionValue(&$context,&$evaluate_context->result,&$argument_value,&$expression_type))
1182: return(0);
1183: }
1184: else
1.10 mlemos 1185: {
1.51 mlemos 1186: if(!IsSet($arguments[$argument_name]["defaultvalue"]))
1187: {
1188: $compiler->SetElementError($context->file,$context->path,"it was not specified the class $function ".$argument_name." argument");
1189: return(0);
1190: }
1191: $argument_value=$arguments[$argument_name]["converteddefaultvalue"];
1.10 mlemos 1192: }
1.70 mlemos 1193: $message["argumentlist"][]=$argument_value;
1.10 mlemos 1194: }
1195: }
1.70 mlemos 1196: if(!$this->language_bindings->Execute(&$compiler,&$context,&$this,$function,&$message))
1197: return(0);
1.4 mlemos 1198: break;
1.12 mlemos 1199: case "return":
1.42 mlemos 1200: if(!$this->GetClassScope(&$compiler,&$arguments_code,&$arguments,&$class,0,$tags))
1.17 mlemos 1201: return(0);
1202: if(!strcmp($this->classes[$class]["return_type"],""))
1.4 mlemos 1203: {
1.12 mlemos 1204: $compiler->SetElementError($context->file,$context->path,"the return function is being from called outside a class function");
1.22 mlemos 1205: return(0);
1206: }
1207: if(!strcmp($this->classes[$class]["return_type"],"VOID"))
1208: {
1209: $compiler->SetElementError($context->file,$context->path,"it was attempted to return a value from a function with return type set to VOID");
1.4 mlemos 1210: return(0);
1211: }
1212: $evaluate_context=$context;
1.17 mlemos 1213: if(!$compiler->GetValidExpression(&$evaluate_context,$this->classes[$class]["return_type"],"NOTLEFT","it was not specified a valid class function return ".$this->classes[$class]["return_type"]." expression",1)
1.11 mlemos 1214: || !$compiler->GetExpressionValue(&$context,&$evaluate_context->result,&$return_value,&$expression_type))
1.4 mlemos 1215: return(0);
1.69 mlemos 1216: $message=array(
1217: "value"=>$return_value
1.4 mlemos 1218: );
1.69 mlemos 1219: if(!$this->language_bindings->Execute(&$compiler,&$context,&$this,"return",&$message))
1220: return(0);
1.17 mlemos 1221: $this->classes[$class]["return_value_set"]=1;
1.1 mlemos 1222: break;
1.12 mlemos 1223: case "instancevariable":
1.69 mlemos 1224: $message=array();
1225: if(!$this->GetClassScope(&$compiler,&$arguments_code,&$arguments,&$message["class"],0,$tags))
1.17 mlemos 1226: return(0);
1.69 mlemos 1227: if(!strcmp($this->classes[$message["class"]]["return_type"],""))
1.6 mlemos 1228: {
1.17 mlemos 1229: $compiler->SetElementError($context->file,$context->path,"the instance variable is being accessed from outside a class function");
1.6 mlemos 1230: return(0);
1231: }
1.69 mlemos 1232: if(!$compiler->GetValidName($context->file,$context->path,&$message["name"],"it was not specified a valid class variable name"))
1.6 mlemos 1233: return(0);
1.69 mlemos 1234: if(!$this->InheritedVariableClass(&$message["class"],$message["name"]))
1.6 mlemos 1235: {
1.69 mlemos 1236: $compiler->SetElementError($context->file,$context->path,"it was not specified a defined class variable name (\"".$message["name"]."\")");
1.6 mlemos 1237: return(0);
1238: }
1.69 mlemos 1239: if(!$this->language_bindings->Execute(&$compiler,&$context,&$this,"instancevariable",&$message))
1240: return(0);
1.9 mlemos 1241: break;
1.12 mlemos 1242: case "objectvariable":
1.9 mlemos 1243: $object_variable=array();
1244: $elements=$arguments_code->structure[$arguments->path]["Elements"];
1245: for($element=0;$element<$elements;$element++)
1246: {
1247: $element_path=$arguments->path.",$element";
1248: $data=$arguments_code->structure[$element_path];
1249: if(GetType($data)=="array")
1250: {
1251: switch($data["Tag"])
1252: {
1.17 mlemos 1253: case "subclass":
1.18 mlemos 1254: if(!$this->GetSubclassArgument(&$compiler,$arguments->file,$element_path,&$object_variable))
1255: return(0);
1.17 mlemos 1256: break;
1.12 mlemos 1257: case "object":
1258: if(IsSet($object_variable["object"]))
1.9 mlemos 1259: {
1.12 mlemos 1260: $compiler->SetElementError($arguments->file,$element_path,"it was specified the class object variable object argument more than once");
1.9 mlemos 1261: return(0);
1262: }
1263: $evaluate_context=$arguments;
1264: $evaluate_context->path=$element_path;
1.12 mlemos 1265: if(!$compiler->GetValidExpression(&$evaluate_context,"OBJECT","NOTLEFT","it was not specified a valid class object variable object expression",1)
1266: || !$compiler->GetExpressionValue(&$context,&$evaluate_context->result,&$object_variable["object"],&$expression_type))
1.9 mlemos 1267: return(0);
1268: break;
1269: default:
1.15 mlemos 1270: $compiler->SetElementError($arguments->file,$element_path,$data["Tag"]." is not a supported class object variable argument");
1.9 mlemos 1271: return(0);
1272: }
1273: }
1274: else
1275: {
1276: if(!$compiler->CheckWhiteSpace($arguments->file,$data,$element_path))
1277: return(0);
1278: }
1279: }
1.12 mlemos 1280: if(!IsSet($object_variable["object"]))
1.9 mlemos 1281: {
1.12 mlemos 1282: $compiler->SetElementError($arguments->file,$arguments->path,"it was not specified the class object variable object argument");
1.9 mlemos 1283: return(0);
1284: }
1.12 mlemos 1285: if(!$compiler->GetValidName($context->file,$context->path,&$name,"it was not specified a valid class variable name"))
1.9 mlemos 1286: return(0);
1.17 mlemos 1287: $subclass=(IsSet($object_variable["subclass"]) ? $object_variable["subclass"] : 0);
1.56 mlemos 1288: if(IsSet($this->classes[$subclass]["abstract"]))
1289: {
1290: $compiler->SetElementError($context->file,$context->path,"abstract class variables can not be accessed");
1291: return(0);
1292: }
1.25 mlemos 1293: if(!$this->InheritedVariableClass(&$subclass,$name))
1.9 mlemos 1294: {
1.35 mlemos 1295: $compiler->SetElementError($context->file,$context->path,"it was not specified a defined class variable name (\"$name\")");
1.9 mlemos 1296: return(0);
1297: }
1.67 mlemos 1298: if(IsSet($this->classes[$subclass]["variables"][$name]["protected"]))
1.52 mlemos 1299: {
1.67 mlemos 1300: $compiler->SetElementError($context->file,$context->path,"it was attempted to access an object protected variable (\"$name\") from outside the class scope");
1.52 mlemos 1301: return(0);
1302: }
1.9 mlemos 1303: $context->result[]=array(
1304: "Data"=>array(
1.12 mlemos 1305: "Value"=>$object_variable["object"]."->$name",
1.17 mlemos 1306: "Type"=>$this->classes[$subclass]["variables"][$name]["type"],
1.21 mlemos 1307: "Side"=>"BOTH"
1.6 mlemos 1308: ),
1309: "Type"=>"EXPRESSION"
1310: );
1311: break;
1.12 mlemos 1312: case "functionargument":
1.69 mlemos 1313: $message=array();
1314: if(!$this->GetClassScope(&$compiler,&$arguments_code,&$arguments,&$message["class"],0,$tags))
1.17 mlemos 1315: return(0);
1.69 mlemos 1316: if(!strcmp($this->classes[$message["class"]]["function_name"],""))
1.10 mlemos 1317: {
1.12 mlemos 1318: $compiler->SetElementError($context->file,$context->path,"the function argument function is being from called outside a class function");
1.10 mlemos 1319: return(0);
1320: }
1.69 mlemos 1321: if(!$compiler->GetValidName($context->file,$context->path,&$message["name"],"it was not specified a valid class function argument name"))
1.10 mlemos 1322: return(0);
1.69 mlemos 1323: if(!IsSet($this->classes[$message["class"]]["functions"][$this->classes[$message["class"]]["function_name"]]["Arguments"][$message["name"]]))
1.10 mlemos 1324: {
1.69 mlemos 1325: $compiler->SetElementError($context->file,$context->path,"it was specified an unknown class function argument (\"".$message["name"]."\")");
1.10 mlemos 1326: return(0);
1327: }
1.68 mlemos 1328: if(!$this->language_bindings->Execute(&$compiler,&$context,&$this,"functionargument",&$message))
1329: return(0);
1.10 mlemos 1330: break;
1.13 mlemos 1331: case "output":
1.42 mlemos 1332: if(!$this->GetClassScope(&$compiler,&$arguments_code,&$arguments,&$class,0,$tags))
1.17 mlemos 1333: return(0);
1.56 mlemos 1334: if(IsSet($this->classes[$class]["abstract"]))
1335: {
1336: $compiler->SetElementError($context->file,$context->path,"abstract classes can not be generated");
1337: return(0);
1338: }
1.17 mlemos 1339: if(!strcmp($this->classes[$class]["file"],""))
1.13 mlemos 1340: {
1341: $compiler->SetElementError($context->file,$context->path,"it was not specified the class output file");
1342: return(0);
1343: }
1.55 mlemos 1344: $message=array(
1345: "class"=>$class,
1346: "result"=>array(),
1347: "initialization"=>array()
1348: );
1349: if(!$this->language_bindings->Execute(&$compiler,&$context,&$this,"output",&$message)
1350: || !$compiler->GenerateOutput(&$context,&$message["result"],&$output,"",0)
1.18 mlemos 1351: || !$compiler->CreateContextOutputDirectory(dirname($this->classes[$class]["file"]),&$context,"it was not possible to create the directory for the class output file \"".dirname($this->classes[$class]["file"])."\""))
1.13 mlemos 1352: return(0);
1.17 mlemos 1353: if(!($output_file=@fopen($this->classes[$class]["file"],"w")))
1.13 mlemos 1354: {
1.17 mlemos 1355: $compiler->SetElementError($context->file,$context->path,"it was not possible to open the class output file \"".$this->classes[$class]["file"]."\"");
1.13 mlemos 1356: return(0);
1357: }
1358: $written=fwrite($output_file,$output);
1359: $closed=fclose($output_file);
1360: if($written!=strlen($output)
1361: || !$closed)
1362: {
1363: $compiler->SetElementError($context->file,$context->path,"it was not possible to write to the class output file");
1364: return(0);
1365: }
1366: $context->result[]=array(
1367: "Data"=>array(
1.17 mlemos 1368: "Name"=>$this->classes[$class]["file"],
1.13 mlemos 1369: "Type"=>"GENERATED"
1370: ),
1371: "Type"=>"FILE"
1372: );
1373: break;
1.17 mlemos 1374: case "subclass":
1375: if(!$this->SetupClass(&$compiler,&$arguments_code,&$arguments))
1376: return(0);
1.42 mlemos 1377: break;
1378: case "getproperty":
1.52 mlemos 1379: case "definedproperty":
1.42 mlemos 1380: if(!$this->GetClassScope(&$compiler,&$arguments_code,&$arguments,&$class,0,$tags))
1381: return(0);
1382: if(!$compiler->GetValidName($context->file,$context->path,&$property,"it was not specified a valid class property name"))
1383: return(0);
1384: switch($property)
1385: {
1386: case "file":
1387: case "basepath":
1388: case "tag":
1.64 mlemos 1389: case "version":
1.52 mlemos 1390: case "copyright":
1.42 mlemos 1391: case "title":
1392: case "author":
1393: case "authoraddress":
1.52 mlemos 1394: if(!strcmp($function,"getproperty"))
1395: {
1396: if(!IsSet($this->classes[$class][$property]))
1397: {
1398: $compiler->SetElementError($context->file,$context->path,"it was requested a property value (\"$property\") not defined for the specified class");
1399: return(0);
1400: }
1401: $context->result[]=array(
1402: "Data"=>$this->classes[$class][$property],
1403: "Type"=>"DATA"
1404: );
1405: }
1406: else
1.42 mlemos 1407: {
1.52 mlemos 1408: $context->result[]=array(
1409: "Data"=>(IsSet($this->classes[$class][$property]) ? "1" : "0"),
1410: "Type"=>"DATA"
1411: );
1.42 mlemos 1412: }
1413: break;
1.64 mlemos 1414: case "subclass":
1415: $context->result[]=array(
1416: "Data"=>(!strcmp($function,"getproperty") ? (IsSet($this->classes[$class]["parent"]) ? "1" : "0") : "1"),
1417: "Type"=>"DATA"
1418: );
1419: break;
1420: case "abstract":
1421: $context->result[]=array(
1422: "Data"=>(!strcmp($function,"getproperty") ? (IsSet($this->classes[$class]["abstract"]) ? "1" : "0") : "1"),
1423: "Type"=>"DATA"
1424: );
1425: break;
1.42 mlemos 1426: default:
1427: $compiler->SetElementError($context->file,$context->path,"\"$property\" is not a supported class property");
1428: return(0);
1429: }
1430: break;
1.45 mlemos 1431: case "definetypes":
1432: if(!$this->GetClassScope(&$compiler,&$arguments_code,&$arguments,&$class,0,$tags))
1433: return(0);
1434: $elements=$code->structure[$context->path]["Elements"];
1435: for($element=0;$element<$elements;$element++)
1436: {
1437: $element_path=$context->path.",$element";
1438: $data=$code->structure[$element_path];
1439: if(GetType($data)=="array")
1440: {
1441: switch($data["Tag"])
1442: {
1443: case "VOID":
1444: case "STRING":
1445: case "INTEGER":
1446: case "FLOAT":
1447: case "BOOLEAN":
1448: case "OBJECT":
1449: case "ARRAY":
1.53 mlemos 1450: case "HASH":
1.45 mlemos 1451: if(IsSet($this->classes[$class]["types"][$data["Tag"]]))
1452: {
1453: $compiler->SetElementError($context->file,$element_path,"it was defined the class data type \"".$data["Tag"]."\" more than once");
1454: return(0);
1455: }
1.63 mlemos 1456: if(!$compiler->GetValidData($context->file,$element_path,&$type,"it was not specified a valid class data type option"))
1.45 mlemos 1457: return(0);
1.63 mlemos 1458: $type_name=$data["Tag"];
1459: $this->classes[$class]["types"][$type_name]=$type;
1460: $parent=$class;
1461: while(IsSet($this->classes[$parent]["parent"]))
1462: {
1463: $parent=$this->classes[$parent]["parent"];
1464: $this->classes[$parent]["types"][$type_name]=$type;
1465: }
1.45 mlemos 1466: break;
1467: default:
1468: $compiler->SetElementError($context->file,$element_path,"it was not defined a valid class data type");
1469: return(0);
1470: }
1471: }
1472: else
1473: {
1474: if(!$compiler->CheckWhiteSpace($context->file,$data,$element_path))
1475: return(0);
1476: }
1477: }
1478: break;
1.42 mlemos 1479: case "forallfunctions":
1480: if(!$this->GetClassScope(&$compiler,&$arguments_code,&$arguments,&$class,1,$tags))
1481: return(0);
1482: if(IsSet($tags["idiom"])
1483: && !$compiler->GetValidName($tags["idiom"]->file,$tags["idiom"]->path,&$idiom,"it was not specified a valid class documentation idiom tag"))
1484: return(0);
1.67 mlemos 1485: $protected=$public=1;
1.60 mlemos 1486: $inherited=0;
1.67 mlemos 1487: if(IsSet($tags["protected"]))
1.52 mlemos 1488: {
1.67 mlemos 1489: if(!$compiler->GetValidData($tags["protected"]->file,$tags["protected"]->path,&$value,"it was not specified a valid class function public value"))
1.52 mlemos 1490: return(0);
1491: switch($value)
1492: {
1493: case "1":
1494: case "":
1.67 mlemos 1495: $protected=1;
1.52 mlemos 1496: break;
1497: case "0":
1.67 mlemos 1498: $protected=0;
1.52 mlemos 1499: break;
1500: default:
1.67 mlemos 1501: $compiler->SetElementError($tags["protected"]->file,$tags["protected"]->path,"it was not specified a valid class function protected value");
1.52 mlemos 1502: return(0);
1503: }
1504: }
1505: if(IsSet($tags["public"]))
1506: {
1507: if(!$compiler->GetValidData($tags["public"]->file,$tags["public"]->path,&$value,"it was not specified a valid class function public value"))
1508: return(0);
1509: switch($value)
1510: {
1511: case "1":
1512: case "":
1513: $public=1;
1514: break;
1515: case "0":
1516: $public=0;
1517: break;
1518: default:
1519: $compiler->SetElementError($tags["public"]->file,$tags["public"]->path,"it was not specified a valid class function public value");
1520: return(0);
1521: }
1522: }
1.59 mlemos 1523: if(IsSet($tags["inherited"]))
1524: {
1525: if(!$compiler->GetValidData($tags["inherited"]->file,$tags["inherited"]->path,&$value,"it was not specified a valid class function inherited value"))
1526: return(0);
1527: switch($value)
1528: {
1529: case "1":
1530: case "":
1531: $inherited=1;
1532: break;
1533: case "0":
1534: $inherited=0;
1535: break;
1536: default:
1537: $compiler->SetElementError($tags["inherited"]->file,$tags["inherited"]->path,"it was not specified a valid class function inherited value");
1538: return(0);
1539: }
1540: }
1.42 mlemos 1541: $functions=array(
1542: "functionname",
1.43 mlemos 1543: "functiontype",
1.45 mlemos 1544: "functiontypename",
1.48 mlemos 1545: "functionistype",
1.59 mlemos 1546: "functionhasarguments",
1.43 mlemos 1547: "forallarguments"
1.42 mlemos 1548: );
1549: if(!$compiler->AddContextFunctions(&$context,$this->object_name,&$functions,&$level))
1550: return(0);
1551: $current_class=$this->current_class;
1552: $current_function=$this->current_function;
1.59 mlemos 1553: $functions=array();
1.67 mlemos 1554: $success=$this->IterateFunctions($compiler,$context,$class,$functions,$protected,$public,$inherited);
1.42 mlemos 1555: $this->current_class=$current_class;
1556: $this->current_function=$current_function;
1.59 mlemos 1557: if(!$compiler->RemoveContextFunctions(&$context,$this->object_name,$level)
1558: || !$success)
1.42 mlemos 1559: return(0);
1560: break;
1.44 mlemos 1561: case "forallvariables":
1562: if(!$this->GetClassScope(&$compiler,&$arguments_code,&$arguments,&$class,1,$tags))
1563: return(0);
1564: if(IsSet($tags["idiom"])
1565: && !$compiler->GetValidName($tags["idiom"]->file,$tags["idiom"]->path,&$idiom,"it was not specified a valid class documentation idiom tag"))
1566: return(0);
1.67 mlemos 1567: $protected=$public=1;
1.59 mlemos 1568: $inherited=0;
1.67 mlemos 1569: if(IsSet($tags["protected"]))
1.52 mlemos 1570: {
1.67 mlemos 1571: if(!$compiler->GetValidData($tags["protected"]->file,$tags["protected"]->path,&$value,"it was not specified a valid class variable public value"))
1.52 mlemos 1572: return(0);
1573: switch($value)
1574: {
1575: case "1":
1576: case "":
1.67 mlemos 1577: $protected=1;
1.52 mlemos 1578: break;
1579: case "0":
1.67 mlemos 1580: $protected=0;
1.52 mlemos 1581: break;
1582: default:
1.67 mlemos 1583: $compiler->SetElementError($tags["protected"]->file,$tags["protected"]->path,"it was not specified a valid class variable protected value");
1.52 mlemos 1584: return(0);
1585: }
1586: }
1587: if(IsSet($tags["public"]))
1588: {
1589: if(!$compiler->GetValidData($tags["public"]->file,$tags["public"]->path,&$value,"it was not specified a valid class variable public value"))
1590: return(0);
1591: switch($value)
1592: {
1593: case "1":
1594: case "":
1595: $public=1;
1596: break;
1597: case "0":
1598: $public=0;
1599: break;
1600: default:
1601: $compiler->SetElementError($tags["public"]->file,$tags["public"]->path,"it was not specified a valid class variable public value");
1602: return(0);
1603: }
1604: }
1.59 mlemos 1605: if(IsSet($tags["inherited"]))
1606: {
1607: if(!$compiler->GetValidData($tags["inherited"]->file,$tags["inherited"]->path,&$value,"it was not specified a valid class variable inherited value"))
1608: return(0);
1609: switch($value)
1610: {
1611: case "1":
1612: case "":
1613: $inherited=1;
1614: break;
1615: case "0":
1616: $inherited=0;
1617: break;
1618: default:
1619: $compiler->SetElementError($tags["inherited"]->file,$tags["inherited"]->path,"it was not specified a valid class variable inherited value");
1620: return(0);
1621: }
1622: }
1.44 mlemos 1623: $functions=array(
1624: "variablename",
1625: "variabletype",
1.45 mlemos 1626: "variabletypename",
1.47 mlemos 1627: "definedvariabledefaultvalue",
1.44 mlemos 1628: "variabledefaultvalue",
1629: "variableconvertedvalue"
1630: );
1631: if(!$compiler->AddContextFunctions(&$context,$this->object_name,&$functions,&$level))
1632: return(0);
1633: $current_class=$this->current_class;
1634: $current_variable=$this->current_variable;
1.59 mlemos 1635: $variables=array();
1.67 mlemos 1636: $success=$this->IterateVariables($compiler,$context,$class,$variables,$protected,$public,$inherited);
1.44 mlemos 1637: $this->current_class=$current_class;
1638: $this->current_variable=$current_variable;
1.59 mlemos 1639: if(!$compiler->RemoveContextFunctions(&$context,$this->object_name,$level)
1640: || !$success)
1.44 mlemos 1641: return(0);
1642: break;
1.43 mlemos 1643: case "forallarguments":
1644: if(!strcmp($this->current_function,""))
1645: {
1646: $compiler->SetElementError($context->file,$context->path,"it was requested to iterate over function arguments outside a function definition scope");
1647: return(0);
1648: }
1649: if(IsSet($tags["idiom"])
1650: && !$compiler->GetValidName($tags["idiom"]->file,$tags["idiom"]->path,&$idiom,"it was not specified a valid class documentation idiom tag"))
1651: return(0);
1.52 mlemos 1652: $current_class=$this->current_class;
1653: $current_function=$this->current_function;
1654: $current_argument=$this->current_argument;
1655: if(!IsSet($this->classes[$current_class]["functions"][$current_function]["Arguments"]))
1656: break;
1.43 mlemos 1657: $functions=array(
1658: "argumentname",
1659: "argumenttype",
1.45 mlemos 1660: "argumenttypename",
1.46 mlemos 1661: "referenceargument",
1.43 mlemos 1662: "lastargument"
1663: );
1664: if(!$compiler->AddContextFunctions(&$context,$this->object_name,&$functions,&$level))
1665: return(0);
1666: for($this->current_argument_number=0,Reset($this->classes[$current_class]["functions"][$current_function]["Arguments"]);$this->current_argument_number<count($this->classes[$current_class]["functions"][$current_function]["Arguments"]);Next($this->classes[$current_class]["functions"][$current_function]["Arguments"]),$this->current_argument_number++)
1667: {
1668: $this->current_class=$current_class;
1669: $this->current_function=$current_function;
1670: $this->current_argument=Key($this->classes[$current_class]["functions"][$current_function]["Arguments"]);
1671: if(!$compiler->GetOutputData($context->file,$context->path,&$context->result,"it was not defined valid action for the class function arguments",0))
1672: {
1673: $this->current_class=$current_class;
1674: $this->current_function=$current_function;
1675: $this->current_argument=$current_argument;
1676: return(0);
1677: }
1678: }
1679: $this->current_class=$current_class;
1680: $this->current_function=$current_function;
1681: $this->current_argument=$current_argument;
1682: if(!$compiler->RemoveContextFunctions(&$context,$this->object_name,$level))
1.64 mlemos 1683: return(0);
1684: break;
1685: case "forallparentclasses":
1686: if(!$this->GetClassScope(&$compiler,&$arguments_code,&$arguments,&$class,1,$tags))
1687: return(0);
1688: if(IsSet($tags["idiom"])
1689: && !$compiler->GetValidName($tags["idiom"]->file,$tags["idiom"]->path,&$idiom,"it was not specified a valid class documentation idiom tag"))
1690: return(0);
1691: $functions=array();
1692: if(!$compiler->AddContextFunctions(&$context,$this->object_name,&$functions,&$level))
1693: return(0);
1694: $current_class=$this->current_class;
1695: $this->current_class=$class;
1696: $success=1;
1697: while(IsSet($this->classes[$this->current_class]["parent"]))
1698: {
1699: $this->current_class=$this->classes[$this->current_class]["parent"];
1700: if(!($success=$compiler->GetOutputData($context->file,$context->path,&$context->result,"it was not defined valid action for the class parentclasses",0)))
1701: break;
1702: }
1703: $this->current_class=$current_class;
1704: if(!$compiler->RemoveContextFunctions(&$context,$this->object_name,$level)
1705: || !$success)
1.43 mlemos 1706: return(0);
1707: break;
1.42 mlemos 1708: case "getdocumentation":
1.44 mlemos 1709: case "defineddocumentation":
1.42 mlemos 1710: if(!$this->GetClassScope(&$compiler,&$arguments_code,&$arguments,&$class,1,$tags))
1711: return(0);
1712: if(!IsSet($tags["idiom"]))
1713: {
1714: $compiler->SetElementError($context->file,$context->path,"it was not specified the class documentation idiom");
1715: return(0);
1716: }
1717: if(!$compiler->GetValidName($tags["idiom"]->file,$tags["idiom"]->path,&$idiom,"it was not specified a valid class documentation idiom tag"))
1718: return(0);
1719: if(!$compiler->GetValidName($context->file,$context->path,&$tag,"it was not specified a valid class documentation tag"))
1720: return(0);
1.61 mlemos 1721: $inherited=0;
1722: if(IsSet($tags["inherited"]))
1723: {
1724: if(!$compiler->GetValidData($tags["inherited"]->file,$tags["inherited"]->path,&$value,"it was not specified a valid class function inherited value"))
1725: return(0);
1726: switch($value)
1727: {
1728: case "1":
1729: case "":
1730: $inherited=1;
1731: break;
1732: case "0":
1733: $inherited=0;
1734: break;
1735: default:
1736: $compiler->SetElementError($tags["inherited"]->file,$tags["inherited"]->path,"it was not specified a valid class function inherited value");
1737: return(0);
1738: }
1739: }
1.44 mlemos 1740: if(strcmp($this->current_argument,""))
1741: {
1.62 mlemos 1742: if($inherited)
1743: {
1744: while(!IsSet($this->classes[$class]["functions"][$this->current_function]["Arguments"][$this->current_argument]["documentation"][$idiom][$tag])
1745: && IsSet($this->classes[$class]["parent"]))
1746: $class=$this->classes[$class]["parent"];
1747: }
1.44 mlemos 1748: if(strcmp($function,"defineddocumentation"))
1749: {
1750: if(!IsSet($this->classes[$class]["functions"][$this->current_function]["Arguments"][$this->current_argument]["documentation"][$idiom][$tag]))
1751: {
1752: $compiler->SetElementError($context->file,$context->path,"it was requested the value of a documentation tag (\"$tag\") that is not defined for the specified class function argument");
1753: return(0);
1754: }
1755: if(!$compiler->GetOutputData($this->classes[$class]["functions"][$this->current_function]["Arguments"][$this->current_argument]["documentation"][$idiom][$tag]->file,$this->classes[$class]["functions"][$this->current_function]["Arguments"][$this->current_argument]["documentation"][$idiom][$tag]->path,&$context->result,"it was not defined valid class function argument documentation tag",0))
1756: return(0);
1757: }
1758: else
1759: {
1760: $context->result[]=array(
1761: "Data"=>(IsSet($this->classes[$class]["functions"][$this->current_function]["Arguments"][$this->current_argument]["documentation"][$idiom][$tag]) ? "1" : "0"),
1762: "Type"=>"DATA"
1763: );
1764: }
1765: }
1766: else
1.42 mlemos 1767: {
1.44 mlemos 1768: if(strcmp($this->current_function,""))
1769: {
1.62 mlemos 1770: if($inherited)
1771: {
1772: while(!IsSet($this->classes[$class]["functions"][$this->current_function]["documentation"][$idiom][$tag])
1773: && IsSet($this->classes[$class]["parent"]))
1774: $class=$this->classes[$class]["parent"];
1775: }
1.44 mlemos 1776: if(strcmp($function,"defineddocumentation"))
1777: {
1778: if(!IsSet($this->classes[$class]["functions"][$this->current_function]["documentation"][$idiom][$tag]))
1779: {
1780: $compiler->SetElementError($context->file,$context->path,"it was requested the value of a documentation tag (\"$tag\") that is not defined for the specified class function");
1781: return(0);
1782: }
1783: if(!$compiler->GetOutputData($this->classes[$class]["functions"][$this->current_function]["documentation"][$idiom][$tag]->file,$this->classes[$class]["functions"][$this->current_function]["documentation"][$idiom][$tag]->path,&$context->result,"it was not defined valid class function argument documentation tag",0))
1784: return(0);
1785: }
1786: else
1787: {
1788: $context->result[]=array(
1789: "Data"=>(IsSet($this->classes[$class]["functions"][$this->current_function]["documentation"][$idiom][$tag]) ? "1" : "0"),
1790: "Type"=>"DATA"
1791: );
1792: }
1793: }
1794: else
1795: {
1796: if(strcmp($this->current_variable,""))
1797: {
1.61 mlemos 1798: if($inherited)
1799: {
1800: while(!IsSet($this->classes[$class]["variables"][$this->current_variable]["documentation"][$idiom][$tag])
1801: && IsSet($this->classes[$class]["parent"]))
1802: $class=$this->classes[$class]["parent"];
1803: }
1.44 mlemos 1804: if(strcmp($function,"defineddocumentation"))
1805: {
1806: if(!IsSet($this->classes[$class]["variables"][$this->current_variable]["documentation"][$idiom][$tag]))
1807: {
1808: $compiler->SetElementError($context->file,$context->path,"it was requested the value of a documentation tag (\"$tag\") that is not defined for the specified class variable");
1809: return(0);
1810: }
1811: if(!$compiler->GetOutputData($this->classes[$class]["variables"][$this->current_variable]["documentation"][$idiom][$tag]->file,$this->classes[$class]["variables"][$this->current_variable]["documentation"][$idiom][$tag]->path,&$context->result,"it was not defined valid class variable argument documentation tag",0))
1812: return(0);
1813: }
1814: else
1815: {
1816: $context->result[]=array(
1817: "Data"=>(IsSet($this->classes[$class]["variables"][$this->current_variable]["documentation"][$idiom][$tag]) ? "1" : "0"),
1818: "Type"=>"DATA"
1819: );
1820: }
1821: }
1822: else
1823: {
1824: if(strcmp($function,"defineddocumentation"))
1825: {
1826: if(!IsSet($this->classes[$class]["documentation"][$idiom][$tag]))
1827: {
1828: $compiler->SetElementError($context->file,$context->path,"it was requested the value of a documentation tag (\"$tag\") that is not defined for the specified class");
1829: return(0);
1830: }
1831: if(!$compiler->GetOutputData($this->classes[$class]["documentation"][$idiom][$tag]->file,$this->classes[$class]["documentation"][$idiom][$tag]->path,&$context->result,"it was not defined valid class documentation tag",0))
1832: return(0);
1833: }
1834: else
1835: {
1836: $context->result[]=array(
1837: "Data"=>(IsSet($this->classes[$class]["documentation"][$idiom][$tag]) ? "1" : "0"),
1838: "Type"=>"DATA"
1839: );
1840: }
1841: }
1842: }
1.42 mlemos 1843: }
1844: break;
1845: case "functionname":
1846: case "functiontype":
1.45 mlemos 1847: case "functiontypename":
1.48 mlemos 1848: case "functionistype":
1.59 mlemos 1849: case "functionhasarguments":
1.42 mlemos 1850: if(!strcmp($this->current_function,""))
1851: {
1.43 mlemos 1852: $compiler->SetElementError($context->file,$context->path,"it was requested the $function of function outside a function definition scope");
1.42 mlemos 1853: return(0);
1854: }
1855: switch($function)
1856: {
1857: case "functionname":
1858: $value=$this->current_function;
1859: break;
1860: case "functiontype":
1861: $value=$this->classes[$this->current_class]["functions"][$this->current_function]["type"];
1.43 mlemos 1862: break;
1.45 mlemos 1863: case "functiontypename":
1864: $value=$this->classes[$this->current_class]["functions"][$this->current_function]["type"];
1865: if(IsSet($this->classes[$this->current_class]["types"][$value]))
1866: $value=$this->classes[$this->current_class]["types"][$value];
1.48 mlemos 1867: break;
1868: case "functionistype":
1869: if(!$compiler->GetValidData($context->file,$context->path,&$type,"it was not specified a valid class function return type"))
1870: return(0);
1871: switch($type)
1872: {
1873: case "VOID":
1874: case "STRING":
1875: case "INTEGER":
1876: case "FLOAT":
1877: case "BOOLEAN":
1878: case "OBJECT":
1879: case "ARRAY":
1.53 mlemos 1880: case "HASH":
1.48 mlemos 1881: break;
1882: default:
1883: $compiler->SetElementError($context->file,$context->path,"it was not defined a valid class function return type");
1884: return(0);
1885: }
1886: $value=(strcmp($type,$this->classes[$this->current_class]["functions"][$this->current_function]["type"]) ? "0" : "1");
1.59 mlemos 1887: break;
1888: case "functionhasarguments":
1889: $value=(IsSet($this->classes[$this->current_class]["functions"][$this->current_function]["Arguments"]) ? "1" : "0");
1.45 mlemos 1890: break;
1.43 mlemos 1891: }
1892: $context->result[]=array(
1893: "Data"=>$value,
1894: "Type"=>"DATA"
1895: );
1896: break;
1897: case "argumentname":
1898: case "argumenttype":
1.45 mlemos 1899: case "argumenttypename":
1.46 mlemos 1900: case "referenceargument":
1.43 mlemos 1901: case "lastargument":
1902: if(!strcmp($this->current_argument,""))
1903: {
1904: $compiler->SetElementError($context->file,$context->path,"it was requested the $function of function argument outside a function argument definition scope");
1905: return(0);
1906: }
1907: switch($function)
1908: {
1909: case "argumentname":
1910: $value=$this->current_argument;
1911: break;
1912: case "argumenttype":
1913: $value=$this->classes[$this->current_class]["functions"][$this->current_function]["Arguments"][$this->current_argument]["type"];
1914: break;
1.45 mlemos 1915: case "argumenttypename":
1916: $value=$this->classes[$this->current_class]["functions"][$this->current_function]["Arguments"][$this->current_argument]["type"];
1917: if(IsSet($this->classes[$this->current_class]["types"][$value]))
1918: $value=$this->classes[$this->current_class]["types"][$value];
1.46 mlemos 1919: break;
1920: case "referenceargument":
1921: $value=(IsSet($this->classes[$this->current_class]["functions"][$this->current_function]["Arguments"][$this->current_argument]["reference"]) ? "1" : "0");
1.45 mlemos 1922: break;
1.43 mlemos 1923: case "lastargument":
1924: $value=($this->current_argument_number+1==count($this->classes[$this->current_class]["functions"][$this->current_function]["Arguments"]) ? "1" : "0");
1.44 mlemos 1925: break;
1926: }
1927: $context->result[]=array(
1928: "Data"=>$value,
1929: "Type"=>"DATA"
1930: );
1931: break;
1932: case "variablename":
1933: case "variabletype":
1.45 mlemos 1934: case "variabletypename":
1.47 mlemos 1935: case "definedvariabledefaultvalue":
1.44 mlemos 1936: case "variabledefaultvalue":
1937: case "variableconvertedvalue":
1938: if(!strcmp($this->current_variable,""))
1939: {
1940: $compiler->SetElementError($context->file,$context->path,"it was requested the $function of variable outside a variable definition scope");
1941: return(0);
1942: }
1943: switch($function)
1944: {
1945: case "variablename":
1946: $value=$this->current_variable;
1947: break;
1948: case "variabletype":
1949: $value=$this->classes[$this->current_class]["variables"][$this->current_variable]["type"];
1.45 mlemos 1950: break;
1951: case "variabletypename":
1952: $value=$this->classes[$this->current_class]["variables"][$this->current_variable]["type"];
1953: if(IsSet($this->classes[$this->current_class]["types"][$value]))
1954: $value=$this->classes[$this->current_class]["types"][$value];
1.44 mlemos 1955: break;
1.47 mlemos 1956: case "definedvariabledefaultvalue":
1957: $value=(IsSet($this->classes[$this->current_class]["variables"][$this->current_variable]["value"]) ? "1" : "0");
1958: break;
1.44 mlemos 1959: case "variabledefaultvalue":
1.47 mlemos 1960: if(!IsSet($this->classes[$this->current_class]["variables"][$this->current_variable]["value"]))
1961: {
1962: $compiler->SetElementError($context->file,$context->path,"it was requested the value of a class variable (".$this->current_variable.") that does not have a defined default value");
1963: return(0);
1964: }
1.44 mlemos 1965: $value=$this->classes[$this->current_class]["variables"][$this->current_variable]["value"];
1966: break;
1967: case "variableconvertedvalue":
1.47 mlemos 1968: if(!IsSet($this->classes[$this->current_class]["variables"][$this->current_variable]["convertedvalue"]))
1969: {
1970: $compiler->SetElementError($context->file,$context->path,"it was requested the convertedvalue of a class variable (".$this->current_variable.") that does not have a defined default value");
1971: return(0);
1972: }
1.44 mlemos 1973: $value=$this->classes[$this->current_class]["variables"][$this->current_variable]["convertedvalue"];
1.42 mlemos 1974: break;
1975: }
1976: $context->result[]=array(
1977: "Data"=>$value,
1.65 mlemos 1978: "Type"=>"DATA"
1979: );
1980: break;
1981: case "examplecode":
1.66 mlemos 1982: if(!$this->GetClassScope(&$compiler,&$arguments_code,&$arguments,&$class,1,$tags))
1983: return(0);
1.65 mlemos 1984: $result=array();
1985: if(!$compiler->GetOutputData($context->file,$context->path,&$result,"invalid example code",1))
1986: return(0);
1.66 mlemos 1987: $initialization=1;
1988: if(IsSet($tags["initialization"]))
1989: {
1990: if(!$compiler->GetValidData($tags["initialization"]->file,$tags["initialization"]->path,&$value,"it was not specified a valid class example code initialization value"))
1991: return(0);
1992: switch($value)
1993: {
1994: case "1":
1995: case "":
1996: $initialization=1;
1997: break;
1998: case "0":
1999: $initialization=0;
2000: break;
2001: default:
2002: $compiler->SetElementError($tags["initialization"]->file,$tags["initialization"]->path,"it was not specified a valid class example code initialization value");
2003: return(0);
2004: }
2005: }
2006: if($initialization)
2007: {
2008: if(!$compiler->GenerateOutput(&$context,&$result,&$output,"",0))
2009: return(0);
2010: }
2011: else
2012: {
2013: for($stripped=array(),$part=0;$part<count($result);$part++)
2014: {
2015: switch($result[$part]["Type"])
2016: {
2017: case "INITIALIZATION":
2018: break;
2019: default:
2020: $stripped[]=$result[$part];
2021: break;
2022: }
2023: }
2024: if(!$compiler->GenerateOutput(&$context,&$stripped,&$output,"",0))
2025: return(0);
2026: }
1.65 mlemos 2027: $context->result[]=array(
2028: "Data"=>$output,
1.42 mlemos 2029: "Type"=>"DATA"
2030: );
1.17 mlemos 2031: break;
1.1 mlemos 2032: default:
1.12 mlemos 2033: $compiler->SetElementError($context->file,$context->path,$function." is not a supported class object function");
1.1 mlemos 2034: return(0);
2035: }
2036: return(1);
2037: }
2038:
1.34 mlemos 2039: Function Initialization(&$compiler,&$context,$object_context)
1.1 mlemos 2040: {
1.12 mlemos 2041: if(strcmp($compiler->language["name"],"PHP"))
1.1 mlemos 2042: {
1.12 mlemos 2043: $compiler->SetElementError($context->file,$context->path,$compiler->language["name"]." is not a language supported by the class class");
1.1 mlemos 2044: return(0);
2045: }
1.34 mlemos 2046: $class=$this->subclasses[$object_context];
1.56 mlemos 2047: if(IsSet($this->classes[$class]["abstract"]))
2048: {
2049: $compiler->SetElementError($context->file,$context->path,"abstract class functions arguments can not be accessed");
2050: return(0);
2051: }
1.66 mlemos 2052: for($parent=$class;$parent!=0 && !IsSet($this->classes[$parent=$this->classes[$parent]["parent"]]["abstract"]);)
1.34 mlemos 2053: {
2054: $context->result[]=array(
2055: "Data"=>array(
2056: "Object"=>$this->object_name,
2057: "Context"=>$this->classes[$parent]["name"]
2058: ),
2059: "Type"=>"INITIALIZATION"
2060: );
2061: }
2062: if(strcmp($this->classes[$class]["file"],""))
1.1 mlemos 2063: {
1.34 mlemos 2064: for(Reset($this->classes[$class]["functions"]),$function=0;$function<count($this->classes[$class]["functions"]);$function++,Next($this->classes[$class]["functions"]))
1.7 mlemos 2065: {
1.34 mlemos 2066: $name=Key($this->classes[$class]["functions"]);
2067: if(!$this->GenerateFunction(&$compiler,$class,$name))
2068: return(0);
2069: for($part=0;$part<count($this->classes[$class]["functions"][$name]["do"]["code"]);$part++)
1.17 mlemos 2070: {
1.40 mlemos 2071: switch($this->classes[$class]["functions"][$name]["do"]["code"][$part]["Type"])
2072: {
2073: case "INITIALIZATION":
2074: case "FILE":
2075: $context->result[]=$this->classes[$class]["functions"][$name]["do"]["code"][$part];
2076: break;
2077: }
1.17 mlemos 2078: }
1.34 mlemos 2079: }
2080: $relative_path=$compiler->RelativePath($this->classes[$class]["basepath"],$this->classes[$class]["file"]);
2081: $context->result[]=array(
2082: "Data"=>array(
2083: "Name"=>$this->classes[$class]["file"],
2084: "Type"=>"SUPPLIED"
2085: ),
2086: "Type"=>"FILE"
2087: );
2088: if($this->classes[$class]["staticload"])
2089: {
1.17 mlemos 2090: $context->result[]=array(
1.34 mlemos 2091: "Data"=>"require(\"$relative_path\");",
2092: "Type"=>"COMMAND"
1.17 mlemos 2093: );
1.15 mlemos 2094: }
1.34 mlemos 2095: }
2096: else
2097: {
1.55 mlemos 2098: $message=array(
2099: "class"=>$class,
2100: "result"=>array(),
2101: "initialization"=>array()
2102: );
2103: if(!$this->language_bindings->Execute(&$compiler,&$context,&$this,"output",&$message))
1.34 mlemos 2104: return(0);
1.55 mlemos 2105: for($part=0;$part<count($message["initialization"]);$part++)
2106: $context->result[]=$message["initialization"][$part];
2107: for($part=0;$part<count($message["result"]);$part++)
2108: $context->result[]=$message["result"][$part];
1.13 mlemos 2109: }
1.1 mlemos 2110: return(1);
2111: }
2112: };
2113:
2114: }
2115: ?>
|