| 169 | } |
| 170 | |
| 171 | VariantType MUtils::UnboxVariantType(MType* type) |
| 172 | { |
| 173 | if (!type) |
| 174 | return VariantType(VariantType::Null); |
| 175 | const auto& stdTypes = *StdTypesContainer::Instance(); |
| 176 | MClass* klass = MCore::Type::GetClass(type); |
| 177 | MTypes types = MCore::Type::GetType(type); |
| 178 | |
| 179 | // Fast type detection for in-built types |
| 180 | switch (types) |
| 181 | { |
| 182 | case MTypes::Void: |
| 183 | return VariantType(VariantType::Void); |
| 184 | case MTypes::Boolean: |
| 185 | return VariantType(VariantType::Bool); |
| 186 | case MTypes::I1: |
| 187 | case MTypes::I2: |
| 188 | return VariantType(VariantType::Int16); |
| 189 | case MTypes::U1: |
| 190 | case MTypes::U2: |
| 191 | return VariantType(VariantType::Uint16); |
| 192 | case MTypes::I4: |
| 193 | case MTypes::Char: |
| 194 | return VariantType(VariantType::Int); |
| 195 | case MTypes::U4: |
| 196 | return VariantType(VariantType::Uint); |
| 197 | case MTypes::I8: |
| 198 | return VariantType(VariantType::Int64); |
| 199 | case MTypes::U8: |
| 200 | return VariantType(VariantType::Uint64); |
| 201 | case MTypes::R4: |
| 202 | return VariantType(VariantType::Float); |
| 203 | case MTypes::R8: |
| 204 | return VariantType(VariantType::Double); |
| 205 | case MTypes::String: |
| 206 | return VariantType(VariantType::String); |
| 207 | case MTypes::Ptr: |
| 208 | return VariantType(VariantType::Pointer); |
| 209 | case MTypes::ValueType: |
| 210 | if (klass == stdTypes.GuidClass) |
| 211 | return VariantType(VariantType::Guid); |
| 212 | if (klass == stdTypes.Vector2Class) |
| 213 | return VariantType(VariantType::Vector2); |
| 214 | if (klass == stdTypes.Vector3Class) |
| 215 | return VariantType(VariantType::Vector3); |
| 216 | if (klass == stdTypes.Vector4Class) |
| 217 | return VariantType(VariantType::Vector4); |
| 218 | if (klass == Int2::TypeInitializer.GetClass()) |
| 219 | return VariantType(VariantType::Int2); |
| 220 | if (klass == Int3::TypeInitializer.GetClass()) |
| 221 | return VariantType(VariantType::Int3); |
| 222 | if (klass == Int4::TypeInitializer.GetClass()) |
| 223 | return VariantType(VariantType::Int4); |
| 224 | if (klass == Float2::TypeInitializer.GetClass()) |
| 225 | return VariantType(VariantType::Float2); |
| 226 | if (klass == Float3::TypeInitializer.GetClass()) |
| 227 | return VariantType(VariantType::Float3); |
| 228 | if (klass == Float4::TypeInitializer.GetClass()) |
nothing calls this directly
no test coverage detected