1 26 27 package org.objectweb.openccm.pss.generator.common.lib; 28 29 import org.objectweb.openccm.ast.api.TypeKind; 31 import org.objectweb.openccm.ast.api.DeclarationKind; 32 import org.objectweb.openccm.ast.api.Declaration; 33 import org.objectweb.openccm.ast.api.StorageTypeStateMemberDecl; 34 import org.objectweb.openccm.ast.api.StorageTypeStoreDirectiveDecl; 35 import org.objectweb.openccm.ast.api.TypeRef; 36 import org.objectweb.openccm.ast.api.StorageTypeDecl; 37 38 43 44 public class PSDLMappingTools 45 extends PSDLTools 46 { 47 48 54 60 63 64 public PSDLMappingTools() 65 { 66 } 67 68 74 80 87 public static String 88 getMarshalledType(TypeRef typeref) 89 { 90 TypeKind tk = typeref.getTypeKind(); 91 92 if (tk == TypeKind.tk_alias) 93 { 94 org.objectweb.openccm.ast.api.AliasDecl alias; 96 97 alias = (org.objectweb.openccm.ast.api.AliasDecl)typeref; 98 return getMarshalledType( alias.getType() ); 99 } 100 101 if ( (tk == TypeKind.tk_sequence) 102 || (tk == TypeKind.tk_array) ) 103 { 104 org.objectweb.openccm.ast.api.TypeRefWithContent content = null; 105 java.lang.String str = null; 106 107 content = (org.objectweb.openccm.ast.api.TypeRefWithContent)typeref; 108 str = getMarshalledType( content.getContentType() ); 109 return str + "[]"; 110 } 111 112 if ( (tk == TypeKind.tk_struct) 113 || ( tk == TypeKind.tk_union) 114 || ( tk == TypeKind.tk_value_box) 115 || ( tk == TypeKind.tk_any) 116 || ( tk == TypeKind.tk_value) ) 117 { 118 return "byte[]"; } 120 else if ( tk == TypeKind.tk_interface) 121 { 122 return "java.lang.String"; } 124 125 return null; 126 } 127 128 136 public static String 137 getMarshalledType(StorageTypeDecl st, 138 StorageTypeStateMemberDecl state) 139 { 140 org.objectweb.openccm.ast.api.PsdlTypeRef psdltyperef = null; 141 org.objectweb.openccm.ast.api.TypeRef idl_type = null; 142 143 psdltyperef = state.getType(); 144 idl_type = psdltyperef.getTypeRef(); 145 146 if (idl_type != null) 147 { 148 return getMarshalledType(idl_type); 149 } 150 else 151 { 152 if (!psdltyperef.isRef()) 154 { 155 org.objectweb.openccm.generator.translator.idl2java.api.PSDL_JavaTranslator translator = null; 156 Declaration[] decls = null; 157 String sd_name = null; 158 159 decls = st.getContents(true, DeclarationKind.dk_storage_type_store_directive); 161 sd_name = state.getName() + "_store_directive"; 162 for (int i=0;i<decls.length;i++) 163 { 164 if (sd_name.compareTo(decls[i].getName()) == 0) 165 { 166 StorageTypeStoreDirectiveDecl sd = (StorageTypeStoreDirectiveDecl)decls[i]; 167 translator = new org.objectweb.openccm.generator.translator.idl2java.lib.PSDL_JavaTranslator(); 168 return translator.toJava(sd.getType()); 169 } 170 } 171 } 172 return null; 173 } 174 } 175 } 176 | Popular Tags |