Esempio n. 1
0
        private static NativeObject BuildDebuggableObject(XaeiOSObject xaeiosObject, VTable vtable, IntRef fieldCounter)
        {
            NativeObject debuggableObject = new NativeObject();

            // add fields from base class
            // update field counter along the way so that we know which slots correspond to which field names
            if (vtable != GetSystemObjectVTable())
            {
                debuggableObject[DebugBaseKey] = var.Cast<NativeObject>(BuildDebuggableObject(
                    xaeiosObject,
                    vtable.BaseVTable,
                    fieldCounter
                ));
            }

            // retreive debug information for class through vtable
            VTableDebugInfo debugInfo = vtable.DebugInfo;

            // apply debug information to object instance
            {
                debuggableObject["FullName"] = var.Cast<string>(debugInfo.FullName);

                // fields
                NativeArray<string> fieldNames = debugInfo.Fields;
                for (int i = 0; i < fieldNames.Length; i++)
                {
                    debuggableObject[fieldNames[i]] = xaeiosObject[fieldCounter.Value + i];
                }
                fieldCounter.Value += fieldNames.Length;
            }

            return debuggableObject;
        }
Esempio n. 2
0
        private static ISynchronizable[] ObjectsToISync(NativeObject[] objects)
        {
            ISynchronizable[] newArray = new ISynchronizable[objects.Length];

            for (int i = 0; i < newArray.Length; i++)
                newArray[i] = objects[i].Handle;

            return newArray;
        }
		public virtual void TestShouldReturnAllPropertiesOfArg()
		{
			NativeObject @object = new NativeObject();
			@object.DefineProperty("a", "1", ScriptableObject.EMPTY);
			@object.DefineProperty("b", "2", ScriptableObject.DONTENUM);
			object result = Evaluator.Eval("Object.getOwnPropertyNames(obj)", "obj", @object);
			NativeArray names = (NativeArray)result;
			NUnit.Framework.Assert.AreEqual(2, names.GetLength());
			NUnit.Framework.Assert.AreEqual("a", names.Get(0, names));
			NUnit.Framework.Assert.AreEqual("b", names.Get(1, names));
		}
Esempio n. 4
0
		public virtual void ShouldReturnOnlyEnumerablePropertiesOfArg()
		{
			NativeObject @object = new NativeObject();
			@object.DefineProperty("a", "1", ScriptableObject.EMPTY);
			@object.DefineProperty("b", "2", ScriptableObject.EMPTY);
			@object.DefineProperty("c", "3", ScriptableObject.DONTENUM);
			object result = Evaluator.Eval("Object.keys(obj)", "obj", @object);
			NativeArray keys = (NativeArray)result;
			NUnit.Framework.Assert.AreEqual(2, keys.GetLength());
			NUnit.Framework.Assert.AreEqual("a", keys.Get(0, keys));
			NUnit.Framework.Assert.AreEqual("b", keys.Get(1, keys));
		}
        public void CloseAllFigures()
        {
            ExtendedGeneralPath p  = new ExtendedGeneralPath();
            PathIterator        pi = NativeObject.getPathIterator(null);
            JPI lastSeg            = JPI.SEG_CLOSE;

            float [] points = new float[6];

            p.setWindingRule(pi.getWindingRule());
            while (!pi.isDone())
            {
                JPI curSeg = (JPI)pi.currentSegment(points);
                switch (curSeg)
                {
                case JPI.SEG_CLOSE:
                    p.closePath();
                    break;

                case JPI.SEG_MOVETO:
                    if (lastSeg != JPI.SEG_CLOSE)
                    {
                        p.closePath();
                    }
                    p.moveTo(points[0], points[1]);
                    break;

                case JPI.SEG_LINETO:
                    p.lineTo(points[0], points[1]);
                    break;

                case JPI.SEG_QUADTO:
                    p.quadTo(points[0], points[1], points[2], points[3]);
                    break;

                case JPI.SEG_CUBICTO:
                    p.curveTo(points[0], points[1], points[2], points[3], points[4], points[5]);
                    break;

                default:
                    break;
                }
                lastSeg = curSeg;
                pi.next();
            }

            p.closePath();
            Shape = p;
        }
        public void Flatten(Matrix matrix, float flatness)
        {
            AffineTransform tr = null;

            if (matrix != null)
            {
                tr = matrix.NativeObject;
            }

            //FIXME : Review (perfomance reasons).
            PathIterator        pi      = NativeObject.getPathIterator(tr, flatness);
            ExtendedGeneralPath newPath = new ExtendedGeneralPath();

            newPath.append(pi, false);
            Shape = newPath;
        }
Esempio n. 7
0
		public NativeCallback() {
			Console.Write("Hi");

			var obj = new NativeObject();
			Console.Write(obj);

			var cfg = new Config {
				nativeObject = obj
			};
			Console.Write(cfg);

			var caller = new NativeCaller(cfg);
			Console.Write(caller);

			caller.Start();
		}
Esempio n. 8
0
        // @SetteRequiredStatementCoverage(100)
        public static int reachState(int a, int b, int c)
        {
            NativeObject obj = new NativeObject();

            obj.calculate(a);
            obj.calculate(b);
            obj.calculate(c);

            if (obj.getX() == 2016)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
		public virtual void TestContentsOfPropertyDescriptorShouldReflectAttributesOfProperty()
		{
			NativeObject descriptor;
			NativeObject @object = new NativeObject();
			@object.DefineProperty("a", "1", ScriptableObject.EMPTY);
			@object.DefineProperty("b", "2", ScriptableObject.DONTENUM | ScriptableObject.READONLY | ScriptableObject.PERMANENT);
			descriptor = (NativeObject)Evaluator.Eval("Object.getOwnPropertyDescriptor(obj, 'a')", "obj", @object);
			NUnit.Framework.Assert.AreEqual("1", descriptor.Get("value"));
			NUnit.Framework.Assert.AreEqual(true, descriptor.Get("enumerable"));
			NUnit.Framework.Assert.AreEqual(true, descriptor.Get("writable"));
			NUnit.Framework.Assert.AreEqual(true, descriptor.Get("configurable"));
			descriptor = (NativeObject)Evaluator.Eval("Object.getOwnPropertyDescriptor(obj, 'b')", "obj", @object);
			NUnit.Framework.Assert.AreEqual("2", descriptor.Get("value"));
			NUnit.Framework.Assert.AreEqual(false, descriptor.Get("enumerable"));
			NUnit.Framework.Assert.AreEqual(false, descriptor.Get("writable"));
			NUnit.Framework.Assert.AreEqual(false, descriptor.Get("configurable"));
		}
        public void AddPolygon(PointF [] points)
        {
            if (points == null)
            {
                throw new ArgumentNullException("points");
            }

            if (points.Length < 3)
            {
                throw new ArgumentException("Invalid parameter used.");
            }

            NativeObject.moveTo(points[0].X, points[0].Y);
            for (int i = 1; i < points.Length; i++)
            {
                NativeObject.lineTo(points[i].X, points[i].Y);
            }
            NativeObject.closePath();
        }
        private void SetPath(Point [] pts, byte [] types)
        {
            NativeObject.Clear();
            if (((PathPointType)types [0] & PathPointType.PathTypeMask) != PathPointType.Start)
            {
                NativeObject.moveTo(pts [0].X, pts [0].Y);
            }

            for (int i = 0; i < pts.Length; i++)
            {
                switch (((PathPointType)types [i] & PathPointType.PathTypeMask))
                {
                case PathPointType.Start:
                    NativeObject.moveTo(pts [i].X, pts [i].Y);
                    break;

                case PathPointType.Line:
                    NativeObject.lineTo(pts [i].X, pts [i].Y);
                    break;

                case PathPointType.Bezier3:
                    float x1 = pts [i].X;
                    float y1 = pts [i].Y;
                    i++;
                    float x2 = pts [i].X;
                    float y2 = pts [i].Y;
                    i++;
                    float x3 = pts [i].X;
                    float y3 = pts [i].Y;
                    NativeObject.curveTo(x1, y1, x2, y2, x3, y3);
                    break;
                }
                if (((PathPointType)types [i] & PathPointType.CloseSubpath) != 0)
                {
                    NativeObject.closePath();
                }

                if (((PathPointType)types [i] & PathPointType.PathMarker) != 0)
                {
                    NativeObject.SetMarkers();
                }
            }
        }
        public void AddBeziers(PointF [] pts)
        {
            if (pts == null)
            {
                throw new ArgumentNullException("points");
            }

            AddBezier(pts [0].X, pts [0].Y,
                      pts [1].X, pts [1].Y,
                      pts [2].X, pts [2].Y,
                      pts [3].X, pts [3].Y);

            for (int i = 4; i < pts.Length; i += 3)
            {
                NativeObject.curveTo(
                    pts [i].X, pts [i].Y,
                    pts [i + 1].X, pts [i + 1].Y,
                    pts [i + 2].X, pts [i + 2].Y);
            }
        }
        public void AddPie(float x, float y, float width, float height, float startAngle, float sweepAngle)
        {
            Shape shape = null;

            if (sweepAngle >= 360)
            {
                shape = new Ellipse2D.Float(x, y, width, height);
            }
            else
            {
                double d1Tod2    = width / height;
                double sqrd1Tod2 = d1Tod2 * d1Tod2;
                double start     = ConvertArcAngle(sqrd1Tod2, startAngle);
                double extent    = ConvertArcAngle(sqrd1Tod2, startAngle + sweepAngle) - start;

                shape = new Arc2D.Double(x, y, width, height, -start, -extent, Arc2D.PIE);
            }

            NativeObject.append(shape, false);
        }
        /// <summary>
        /// Based on http://pubpages.unh.edu/~cs770/a5/cardinal.html
        /// </summary>
        /// <param name="pts">point array (x1,y1,x2,y2 ...).
        /// The first and last points considered only for calculations, but are not added.</param>
        void AddCurve(float[] pts, bool connect, float tension)
        {
            tension /= 3f; //looks like a good pick

            if (connect)
            {
                NativeObject.lineTo(pts[2], pts[3]);
            }
            else
            {
                NativeObject.moveTo(pts[2], pts[3]);
            }

            float dx = pts[4] - pts[0];
            float dy = pts[5] - pts[1];

            float sx = pts[2] + tension * dx;
            float sy = pts[3] + tension * dy;

            for (int offset = 2, total = pts.Length - 4; offset < total; offset += 2)
            {
                int cur_offset = offset;
                int pX         = cur_offset++;
                int pY         = cur_offset++;
                int X          = cur_offset++;
                int Y          = cur_offset++;
                int nX         = cur_offset++;
                int nY         = cur_offset++;

                dx = pts[nX] - pts[pX];
                dy = pts[nY] - pts[pY];

                float rx = pts[X] - tension * dx;
                float ry = pts[Y] - tension * dy;

                NativeObject.curveTo(sx, sy, rx, ry, pts[X], pts[Y]);

                sx = pts[X] + tension * dx;
                sy = pts[Y] + tension * dy;
            }
        }
        void AddString(string s, Font font,
                       float x, float y, float width, float height,
                       StringFormat format)
        {
            TextLineIterator iter = new TextLineIterator(s, font,
                                                         new java.awt.font.FontRenderContext(null, false, false),
                                                         format, width, height);

            int coordsCount = NativeObject.CoordsCount;

            for (LineLayout layout = iter.NextLine(); layout != null; layout = iter.NextLine())
            {
                NativeObject.append(layout.GetOutline(x, y), false);
            }

            AffineTransform lineAlignT = iter.CalcLineAlignmentTransform();

            if (lineAlignT != null)
            {
                NativeObject.transform(lineAlignT, coordsCount, NativeObject.CoordsCount - coordsCount);
            }
        }
Esempio n. 16
0
 internal RuntimeObject ResolveRuntimeObject(object target)
 {
     if (target == null)
     {
         return(null);
     }
     if (target is EcmaValue value)
     {
         target = value.GetUnderlyingObject();
     }
     if (target is RuntimeObject runtimeObject)
     {
         if (runtimeObject.Realm == this)
         {
             return(runtimeObject);
         }
         if (TryResolveRuntimeObjectInRealm(runtimeObject, out RuntimeObject sharedObject))
         {
             return(sharedObject);
         }
         return(runtimeObject.Clone(this));
     }
     return(nativeWrappers.GetOrAdd(NativeObject.Create(target)));
 }
Esempio n. 17
0
        public void UpdatePlatformValues(LinkedSurfaces linkedSurface)
        {
            this.linkedSurface = linkedSurface;
            speed = (float)NativeObject.Speed / 30f;
            delay = (float)NativeObject.Delay / 30f;

            var minimumHeight = NativeObject.RuntimeMinimumHeight(ParentLevel.Level);
            var maximumHeight = NativeObject.RuntimeMaximumHeight(ParentLevel.Level);

            if (NativeObject.ComesFromFloor && NativeObject.ComesFromCeiling)
            {
                extendedPosition = (float)(maximumHeight + minimumHeight) / 2f / GeometryUtilities.WorldUnitIncrementsPerMeter;

                if (linkedSurface == LinkedSurfaces.Floor)
                {
                    contractedPosition = (float)minimumHeight / GeometryUtilities.WorldUnitIncrementsPerMeter;
                }
                else
                {
                    contractedPosition = (float)maximumHeight / GeometryUtilities.WorldUnitIncrementsPerMeter;
                }
            }
            else
            {
                if (linkedSurface == LinkedSurfaces.Floor)
                {
                    extendedPosition   = (float)maximumHeight / GeometryUtilities.WorldUnitIncrementsPerMeter;
                    contractedPosition = (float)minimumHeight / GeometryUtilities.WorldUnitIncrementsPerMeter;
                }
                else
                {
                    extendedPosition   = (float)minimumHeight / GeometryUtilities.WorldUnitIncrementsPerMeter;
                    contractedPosition = (float)maximumHeight / GeometryUtilities.WorldUnitIncrementsPerMeter;
                }
            }
        }
Esempio n. 18
0
 public WaitStatus SignalAndWait(NativeObject obj)
 {
     return (WaitStatus)_handle.SignalAndWait(obj.Handle);
 }
Esempio n. 19
0
 public WaitStatus SignalAndWait(NativeObject obj, int timeout)
 {
     return (WaitStatus)_handle.SignalAndWait(obj.Handle, false, timeout * Win32.TimeMsTo100Ns);
 }
 public PointF GetLastPoint()
 {
     return(NativeObject.GetLastPoint());
 }
Esempio n. 21
0
 public static void WaitAny(NativeObject[] objects, DateTime timeout)
 {
     NativeHandle.WaitAny(ObjectsToISync(objects), false, timeout.ToFileTime(), false);
 }
Esempio n. 22
0
 public static bool IsDisposed(this NativeObject obj) =>
 (bool)isDisposedField.GetValue(obj);
Esempio n. 23
0
 public static ref UIntPtr RefPointer(this NativeObject nativeObject)
 {
     return(ref PointerFieldGetter(nativeObject));
 }
 public void Scale(float scaleX, float scaleY)
 {
     NativeObject.scale(scaleX, scaleY);
 }
 public void Translate(float offsetX, float offsetY)
 {
     NativeObject.translate(offsetX, offsetY);
 }
 public override int GetHashCode()
 {
     return(NativeObject.GetHashCode());
 }
 public void Rotate(float angle)
 {
     NativeObject.rotate(JMath.toRadians(angle));
 }
        public void AddEllipse(float x, float y, float width, float height)
        {
            Ellipse2D e = new Ellipse2D.Float(x, y, width, height);

            NativeObject.append(e, false);
        }
 public void Reverse()
 {
     NativeObject.Reverse();
 }
 public void Reset()
 {
     NativeObject.reset();
 }
Esempio n. 31
0
		public EventHandlerTest() {
			HasFired = false;
			native = new NativeObject();
			native.onmouseover = native_OnMouseOver;
		}
Esempio n. 32
0
		public NativeCallbackTest() {
			var obj = new NativeObject();

			var cfg = new Config {
				nativeObject = obj
			};

			var caller = new NativeCaller(cfg);
			caller.Start();
		}
Esempio n. 33
0
 public static extern string[] GetKeys(NativeObject obj);
Esempio n. 34
0
 public static void WaitAny(NativeObject[] objects)
 {
     NativeHandle.WaitAny(ObjectsToISync(objects));
 }
        public void AddBezier(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
        {
            CubicCurve2D cc = new CubicCurve2D.Float(x1, y1, x2, y2, x3, y3, x4, y4);

            NativeObject.append(cc);
        }
Esempio n. 36
0
 public static void WaitAny(NativeObject[] objects, int timeout)
 {
     NativeHandle.WaitAny(ObjectsToISync(objects), false, timeout * Win32.TimeMsTo100Ns, true);
 }
 public Matrix Clone()
 {
     return(new Matrix((geom.AffineTransform)NativeObject.clone()));
 }
        public void AddLine(float x1, float y1, float x2, float y2)
        {
            Line2D l = new Line2D.Float(x1, y1, x2, y2);

            NativeObject.append(l);
        }
 public void Reset()
 {
     NativeObject.setToIdentity();
 }
 public void ClearMarkers()
 {
     NativeObject.ClearMarkers();
 }
 public void RotateAt(float angle, PointF point)
 {
     NativeObject.rotate(JMath.toRadians(angle), point.X, point.Y);
 }
Esempio n. 42
0
		public ObjectWrapperTest() {
			var native = new NativeObject();
			native.Alert(AlertArg);
		}
 public void Shear(float shearX, float shearY)
 {
     NativeObject.shear(shearX, shearY);
 }
Esempio n. 44
0
 private static MODL ResolveModel(BrModel *model)
 {
     return(NativeObject.FromPointer <MODL>(new IntPtr(*(void **)model->Identifier)));
 }
        static unsafe void ExportStructData()
        {
            Directory.CreateDirectory(OutputDirectory);
            var flags = TransferInstructionFlags.SerializeGameRelease;

            using var bw = new BinaryWriter(File.OpenWrite(Path.Combine(OutputDirectory, "structs.dat")));

            foreach (char c in Application.unityVersion)
            {
                bw.Write((byte)c);
            }
            bw.Write((byte)0);

            bw.Write((int)Application.platform);
            bw.Write((byte)1); // hasTypeTrees
            var countPosition = (int)bw.BaseStream.Position;
            var typeCount     = 0;

            for (int i = 0; i < RuntimeTypes.Count; i++)
            {
                var type = RuntimeTypes.Types[i];
                var iter = type;

                while (iter->IsAbstract)
                {
                    if (iter->Base == null)
                    {
                        goto NextType;
                    }

                    iter = iter->Base;
                }

                var obj = NativeObject.GetOrProduce(*iter);

                if (obj == null)
                {
                    continue;
                }

                var tree = new TypeTree();
                tree.Init();
                if (obj->GetTypeTree(flags, ref tree))
                {
                    // Shouldn't this write type.PersistentTypeID instead?
                    // I'm leaving it as iter.PersistentTypeID for consistency
                    // with existing C++ code that generates structs.dat
                    bw.Write((int)iter->PersistentTypeID);

                    // GUID
                    for (int j = 0, n = (int)iter->PersistentTypeID < 0 ? 0x20 : 0x10; j < n; ++j)
                    {
                        bw.Write((byte)0);
                    }

                    TypeTreeUtility.CreateBinaryDump(tree, bw);
                    typeCount++;
                }

                NativeObject.DestroyIfNotSingletonOrPersistent(obj);

NextType:
                continue;
            }

            bw.Seek(countPosition, SeekOrigin.Begin);
            bw.Write(typeCount);
        }
Esempio n. 46
0
 public WaitStatus SignalAndWait(NativeObject obj, DateTime timeout)
 {
     return (WaitStatus)_handle.SignalAndWait(obj.Handle, false, timeout.ToFileTime(), false);
 }