============ idScriptObject::GetVariable ============ */
| 1078 | ============ |
| 1079 | */ |
| 1080 | byte *idScriptObject::GetVariable( const char *name, etype_t etype ) const { |
| 1081 | int i; |
| 1082 | int pos; |
| 1083 | const idTypeDef *t; |
| 1084 | const idTypeDef *parm; |
| 1085 | |
| 1086 | if ( type == &type_object ) { |
| 1087 | return NULL; |
| 1088 | } |
| 1089 | |
| 1090 | t = type; |
| 1091 | do { |
| 1092 | if ( t->SuperClass() != &type_object ) { |
| 1093 | pos = t->SuperClass()->Size(); |
| 1094 | } else { |
| 1095 | pos = 0; |
| 1096 | } |
| 1097 | for( i = 0; i < t->NumParameters(); i++ ) { |
| 1098 | parm = t->GetParmType( i ); |
| 1099 | if ( !strcmp( t->GetParmName( i ), name ) ) { |
| 1100 | if ( etype != parm->FieldType()->Type() ) { |
| 1101 | return NULL; |
| 1102 | } |
| 1103 | return &data[ pos ]; |
| 1104 | } |
| 1105 | |
| 1106 | if ( parm->FieldType()->Inherits( &type_object ) ) { |
| 1107 | pos += type_object.Size(); |
| 1108 | } else { |
| 1109 | pos += parm->FieldType()->Size(); |
| 1110 | } |
| 1111 | } |
| 1112 | t = t->SuperClass(); |
| 1113 | } while( t && ( t != &type_object ) ); |
| 1114 | |
| 1115 | return NULL; |
| 1116 | } |
| 1117 | |
| 1118 | /*********************************************************************** |
| 1119 |
no test coverage detected