示例#1
0
        bool IsExtVector(Decl decl, QualType type, ref string simd_type)
        {
            var rv = false;
            var t  = type.CanonicalQualType.Type;

            // Unpoint the type
            var pointerType = t as Clang.Ast.PointerType;

            if (pointerType != null)
            {
                t = pointerType.PointeeQualType.Type;
            }

            if (t.Kind == TypeKind.ExtVector)
            {
                rv = true;
            }
            else
            {
                var r = (t as RecordType)?.Decl;
                if (r != null)
                {
                    foreach (var f in r.Fields)
                    {
                        var qt = f.QualType.CanonicalQualType.Type;
                        if (qt.Kind == TypeKind.ExtVector)
                        {
                            rv = true;
                            break;
                        }
                        var at = qt as ConstantArrayType;
                        if (at != null)
                        {
                            if (at.ElementType.Type.Kind == TypeKind.ExtVector)
                            {
                                rv = true;
                                break;
                            }
                        }
                    }
                }
            }

            var typeName = type.ToString();

            if (!rv && typeName.Contains("simd"))
            {
                var framework = Helpers.GetFramework(decl);
                Log.On(framework).Add($"!unknown-simd-type! Could not detect that {typeName} is a Simd type, but its name contains 'simd'. Something needs fixing in SimdCheck.cs");
            }

            if (rv)
            {
                simd_type = typeName;
            }

            return(rv);
        }
示例#2
0
        bool IsSimdType(QualType type, ref string simd_type, ref bool requires_marshal_directive)
        {
            var str = Undecorate(type.ToString());

            if (type_mapping.TryGetValue(str, out var info))
            {
                requires_marshal_directive = true;
                simd_type = str;
                return(true);
            }

            if (IsExtVector(type, ref simd_type))
            {
                Console.WriteLine($"!unknown-simd-type-mapping! The Simd type {simd_type} does not have a mapping to a managed type. Please add one in SimdCheck.cs");
            }

            return(false);
        }
示例#3
0
        bool IsSimdType(Decl decl, QualType type, ref string simd_type, ref bool requires_marshal_directive)
        {
            var str = Undecorate(type.ToString());

            if (type_mapping.TryGetValue(str, out var info))
            {
                requires_marshal_directive = true;
                simd_type = str;
                return(true);
            }

            if (IsExtVector(decl, type, ref simd_type))
            {
                var framework = Helpers.GetFramework(decl);
                Log.On(framework).Add($"!unknown-simd-type-mapping! The Simd type {simd_type} does not have a mapping to a managed type. Please add one in SimdCheck.cs");
            }

            return(false);
        }
示例#4
0
文件: CxxBinder.cs 项目: corefan/urho
		// Temporary, just to help us get the bindings bootstrapped
		// 
		// This limits which C++ types we can bind, and lets us progressively add more
		static bool IsUnsupportedType(QualType qt, bool returnType = false)
		{
			var ct = CleanType(qt);
			var ctstring = ct.ToString ();

			// String references are hand-bound, so we are going to let those though
			if (ctstring == ConstStringReference || ctstring == "const Urho3D::String &")
				return false;

			switch (ctstring) {
			case "const class Urho3D::Vector3 &":
			case "const class Urho3D::IntRect &":
			case "const class Urho3D::Color &":
			case "const class Urho3D::Vector2 &":
			case "const class Urho3D::Vector4 &":
			case "const class Urho3D::IntVector2 &":
			case "const class Urho3D::Quaternion &":
			case "const class Urho3D::Plane &":
			case "const class Urho3D::BoundingBox &":
			case "const struct Urho3D::BiasParameters &":
			case "const struct Urho3D::CascadeParameters &":
			case "const struct Urho3D::TileMapInfo2D &":
			case "const class Urho3D::XMLElement &":
			case "class Urho3D::XMLElement &":
			case "struct Urho3D::PhysicsRaycastResult &":
			case "const class Urho3D::Ray &":
			case "const struct Urho3D::CrowdObstacleAvoidanceParams &":
			case "class Urho3D::Serializer &":
			case "class Urho3D::Deserializer &":
					return false;
			}

			if (returnType) {
				switch (ctstring) {
				case "const Vector<SharedPtr<class Urho3D::Node> > &":
				case "const Vector<SharedPtr<class Urho3D::Component> > &":
				case "const Vector<SharedPtr<class Urho3D::VertexBuffer> > &":
				case "const Vector<SharedPtr<class Urho3D::IndexBuffer> > &":
				case "const Vector<SharedPtr<class Urho3D::UIElement> > &":
				case "const Vector<SharedPtr<class Urho3D::PackageFile> > &":
				case "const Vector<SharedPtr<class Urho3D::Texture2D> > &":
				case "const Vector<SharedPtr<class Urho3D::AnimationState> > &":
					return false;
				}
#if false
				if (ctstring.Contains ("Vector")) {
					if (!displayed.Contains (ctstring)) {
						Console.WriteLine (ctstring);
						displayed.Add (ctstring);
					}
				}
#endif
			} else {
				// The & at the end is redundant, Urho always uses PODVector & on parameters
				// but there for future proofing.
				if (ctstring.Contains ("PODVector<") && ctstring.EndsWith ("&")) {
					string plainPodClass = StringUtil.DropConstAndReference (ctstring);
					// Now, white list the classes we know about, for now
					// we are going to bind the ones that are UrhoObjects 
					switch (plainPodClass) {
					case "PODVector<class Urho3D::Node *>":
					case "PODVector<class Urho3D::Component *>":
					case "PODVector<class Urho3D::VertexBuffer *>":
					case "PODVector<class Urho3D::RigidBody *>":
					case "PODVector<class Urho3D::RigidBody2d *>":
					case "PODVector<class Urho3D::Resource *>":
						podClasses.Add (plainPodClass);
						break;
					default:
						missingPodClasses.Add (plainPodClass);
						break;
					}
				}
			}

			if (ctstring.StartsWith("SharedPtr<") && returnType)
				return false;

			var s = ct.Bind().ToString();
			if (s.Contains ("unsupported")) {
				return true;
			}

			// Quick hack, just while we get thigns going
			if (s.Contains("EventHandler**")) {
				return true;
			}
			if (s.Contains("b2") || s.Contains ("bt"))
				return true;
			
			// Candidate for a hand binding (Connection.h)
			if (qt.ToString().Contains("kNet::SharedPtr"))
				return true;
			if (s.Contains("XMLElement"))
				return true;
			if (s.Contains ("CollisionGeometryData"))
				return true;
			if (s.Contains ("SDL"))
				return true;
			return false;
		}