--- metal/metal_class.php 2001/04/22 19:24:16 1.44 +++ metal/metal_class.php 2001/04/22 21:50:20 1.45 @@ -6,7 +6,7 @@ if(!defined("METAL_CLASS_INCLUDED")) /* * metal_class.php * - * @(#) $Header: /opt2/mlemos/cvs/metal/metal/metal_class.php,v 1.44 2001/04/22 19:24:16 mlemos Exp $ + * @(#) $Header: /opt2/mlemos/cvs/metal/metal/metal_class.php,v 1.45 2001/04/22 21:50:20 mlemos Exp $ * */ @@ -80,6 +80,7 @@ class metal_class_class extends metal_ba $this->classes[$index]["return_type"]=""; $this->classes[$index]["return_value_set"]=0; $this->classes[$index]["staticload"]=0; + $this->classes[$index]["types"]=array(); $this->classes[$index]["functions"]=array(); $this->classes[$index]["variables"]=array(); $this->classes[$index]["declarationfile"]=$attributes->file; @@ -211,6 +212,7 @@ class metal_class_class extends metal_ba case "VOID": case "STRING": case "INTEGER": + case "FLOAT": case "BOOLEAN": case "OBJECT": case "ARRAY": @@ -270,6 +272,7 @@ class metal_class_class extends metal_ba { case "STRING": case "INTEGER": + case "FLOAT": case "BOOLEAN": case "OBJECT": case "ARRAY": @@ -415,6 +418,7 @@ class metal_class_class extends metal_ba { case "STRING": case "INTEGER": + case "FLOAT": case "BOOLEAN": case "OBJECT": case "ARRAY": @@ -1407,6 +1411,46 @@ class metal_class_class extends metal_ba return(0); } break; + case "definetypes": + if(!$this->GetClassScope(&$compiler,&$arguments_code,&$arguments,&$class,0,$tags)) + return(0); + $elements=$code->structure[$context->path]["Elements"]; + for($element=0;$element<$elements;$element++) + { + $element_path=$context->path.",$element"; + $data=$code->structure[$element_path]; + if(GetType($data)=="array") + { + switch($data["Tag"]) + { + case "VOID": + case "STRING": + case "INTEGER": + case "FLOAT": + case "BOOLEAN": + case "OBJECT": + case "ARRAY": + case "ASSOCIATIVEARRAY": + if(IsSet($this->classes[$class]["types"][$data["Tag"]])) + { + $compiler->SetElementError($context->file,$element_path,"it was defined the class data type \"".$data["Tag"]."\" more than once"); + return(0); + } + if(!$compiler->GetValidData($context->file,$element_path,&$this->classes[$class]["types"][$data["Tag"]],"it was not specified a valid class data type option")) + return(0); + break; + default: + $compiler->SetElementError($context->file,$element_path,"it was not defined a valid class data type"); + return(0); + } + } + else + { + if(!$compiler->CheckWhiteSpace($context->file,$data,$element_path)) + return(0); + } + } + break; case "forallfunctions": if(!$this->GetClassScope(&$compiler,&$arguments_code,&$arguments,&$class,1,$tags)) return(0); @@ -1416,6 +1460,7 @@ class metal_class_class extends metal_ba $functions=array( "functionname", "functiontype", + "functiontypename", "forallarguments" ); if(!$compiler->AddContextFunctions(&$context,$this->object_name,&$functions,&$level)) @@ -1447,6 +1492,7 @@ class metal_class_class extends metal_ba $functions=array( "variablename", "variabletype", + "variabletypename", "variabledefaultvalue", "variableconvertedvalue" ); @@ -1482,6 +1528,7 @@ class metal_class_class extends metal_ba $functions=array( "argumentname", "argumenttype", + "argumenttypename", "lastargument" ); if(!$compiler->AddContextFunctions(&$context,$this->object_name,&$functions,&$level)) @@ -1610,6 +1657,7 @@ class metal_class_class extends metal_ba break; case "functionname": case "functiontype": + case "functiontypename": if(!strcmp($this->current_function,"")) { $compiler->SetElementError($context->file,$context->path,"it was requested the $function of function outside a function definition scope"); @@ -1623,6 +1671,11 @@ class metal_class_class extends metal_ba case "functiontype": $value=$this->classes[$this->current_class]["functions"][$this->current_function]["type"]; break; + case "functiontypename": + $value=$this->classes[$this->current_class]["functions"][$this->current_function]["type"]; + if(IsSet($this->classes[$this->current_class]["types"][$value])) + $value=$this->classes[$this->current_class]["types"][$value]; + break; } $context->result[]=array( "Data"=>$value, @@ -1631,6 +1684,7 @@ class metal_class_class extends metal_ba break; case "argumentname": case "argumenttype": + case "argumenttypename": case "lastargument": if(!strcmp($this->current_argument,"")) { @@ -1645,6 +1699,11 @@ class metal_class_class extends metal_ba case "argumenttype": $value=$this->classes[$this->current_class]["functions"][$this->current_function]["Arguments"][$this->current_argument]["type"]; break; + case "argumenttypename": + $value=$this->classes[$this->current_class]["functions"][$this->current_function]["Arguments"][$this->current_argument]["type"]; + if(IsSet($this->classes[$this->current_class]["types"][$value])) + $value=$this->classes[$this->current_class]["types"][$value]; + break; case "lastargument": $value=($this->current_argument_number+1==count($this->classes[$this->current_class]["functions"][$this->current_function]["Arguments"]) ? "1" : "0"); break; @@ -1656,6 +1715,7 @@ class metal_class_class extends metal_ba break; case "variablename": case "variabletype": + case "variabletypename": case "variabledefaultvalue": case "variableconvertedvalue": if(!strcmp($this->current_variable,"")) @@ -1671,6 +1731,11 @@ class metal_class_class extends metal_ba case "variabletype": $value=$this->classes[$this->current_class]["variables"][$this->current_variable]["type"]; break; + case "variabletypename": + $value=$this->classes[$this->current_class]["variables"][$this->current_variable]["type"]; + if(IsSet($this->classes[$this->current_class]["types"][$value])) + $value=$this->classes[$this->current_class]["types"][$value]; + break; case "variabledefaultvalue": $value=$this->classes[$this->current_class]["variables"][$this->current_variable]["value"]; break;