Rev | Line | |
---|
[71] | 1 | #include "common.h"
|
---|
| 2 |
|
---|
| 3 | const int Type::basicTypeList[] = {
|
---|
| 4 | DEF_BYTE,
|
---|
| 5 | DEF_SBYTE,
|
---|
| 6 | DEF_WORD,
|
---|
| 7 | DEF_INTEGER,
|
---|
| 8 | DEF_DWORD,
|
---|
| 9 | DEF_LONG,
|
---|
| 10 | DEF_QWORD,
|
---|
| 11 | DEF_INT64,
|
---|
| 12 |
|
---|
| 13 | DEF_SINGLE,
|
---|
| 14 | DEF_DOUBLE,
|
---|
| 15 |
|
---|
| 16 | DEF_BOOLEAN,
|
---|
| 17 |
|
---|
| 18 | DEF_PTR_VOID,
|
---|
| 19 |
|
---|
| 20 | DEF_ANY,
|
---|
| 21 |
|
---|
| 22 | DEF_NON
|
---|
| 23 | };
|
---|
| 24 |
|
---|
| 25 | const string Type::basicTypeNameList[] = {
|
---|
| 26 | "Byte",
|
---|
| 27 | "SByte",
|
---|
| 28 | "Word",
|
---|
| 29 | "Integer",
|
---|
| 30 | "DWord",
|
---|
| 31 | "Long",
|
---|
| 32 | "QWord",
|
---|
| 33 | "Int64",
|
---|
| 34 |
|
---|
| 35 | "Single",
|
---|
| 36 | "Double",
|
---|
| 37 |
|
---|
| 38 | "Boolean",
|
---|
| 39 |
|
---|
| 40 | "VoidPtr",
|
---|
| 41 |
|
---|
| 42 | "Any",
|
---|
| 43 |
|
---|
| 44 | ""
|
---|
| 45 | };
|
---|
| 46 |
|
---|
| 47 | bool Type::StringToBasicType( const string &typeName, int &basicType ){
|
---|
| 48 | for( int i=0; ; i++ ){
|
---|
| 49 | if( basicTypeList[i] == DEF_NON ){
|
---|
| 50 | break;
|
---|
| 51 | }
|
---|
| 52 | if( basicTypeNameList[i] == typeName ){
|
---|
| 53 | basicType = basicTypeList[i];
|
---|
| 54 | return true;
|
---|
| 55 | }
|
---|
| 56 | }
|
---|
| 57 | return false;
|
---|
| 58 | }
|
---|
| 59 | bool Type::StringToType( const string &typeName, Type &type ){
|
---|
| 60 | type.index = -1;
|
---|
| 61 |
|
---|
| 62 | if( typeName[0] == '*' ){
|
---|
| 63 | if( typeName.size() >= 3
|
---|
| 64 | && typeName[1] == 1 && ( typeName[2] == ESC_FUNCTION || typeName[2] == ESC_SUB ) ){
|
---|
| 65 | //関数ポインタ(*Function)
|
---|
| 66 | type.basicType = DEF_PTR_PROC;
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | string nextTypeName = typeName.substr( 1 );
|
---|
| 70 |
|
---|
| 71 | if( !StringToType( nextTypeName, type ) ){
|
---|
| 72 | return false;
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | type.PtrLevelUp();
|
---|
| 76 |
|
---|
| 77 | return true;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | if( StringToBasicType( typeName, type.basicType ) ){
|
---|
| 81 | // 基本型だったとき
|
---|
| 82 | return true;
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 |
|
---|
| 86 | ////////////////////
|
---|
| 87 | // TypeDefされた型
|
---|
| 88 | ////////////////////
|
---|
| 89 | int i=pobj_DBTypeDef->check( typeName.c_str() );
|
---|
| 90 | if(i!=-1){
|
---|
| 91 | return StringToType( pobj_DBTypeDef->ppobj_TypeDef[i]->lpszBaseName, type );
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | //クラス
|
---|
| 95 | CClass *pobj_c = pobj_DBClass->check( typeName.c_str() );
|
---|
| 96 | if(pobj_c){
|
---|
| 97 | type.pClass = pobj_c;
|
---|
| 98 |
|
---|
| 99 | if( pobj_c->IsStructure() ){
|
---|
| 100 | type.basicType = DEF_STRUCT;
|
---|
| 101 | }
|
---|
| 102 | else{
|
---|
| 103 | type.basicType = DEF_OBJECT;
|
---|
| 104 | }
|
---|
| 105 | return true;
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | return false;
|
---|
| 109 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.