2 * Copyright (c) 2023 Codefoco (codefoco@codefoco.com)
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 using System.Runtime.InteropServices;
26 namespace Tizen.NUI.Physics2D.Chipmunk
29 /// Create a ToFunctionPointer extension method for each delegate type. Unfortunately C# 7.0
30 /// can't do something like that (you will need C# 7.3), thus we create one extension method for
31 /// each delegate public static IntPtr ToFunctionPointer T (this T d) where T : Delegate
33 static internal class DelegateExtensions
35 public static IntPtr ToFunctionPointer(this BodyArbiterIteratorFunction d)
42 return Marshal.GetFunctionPointerForDelegate<BodyArbiterIteratorFunction>(d);
45 public static IntPtr ToFunctionPointer(this BodyConstraintIteratorFunction d)
52 return Marshal.GetFunctionPointerForDelegate<BodyConstraintIteratorFunction>(d);
55 public static IntPtr ToFunctionPointer(this BodyShapeIteratorFunction d)
62 return Marshal.GetFunctionPointerForDelegate<BodyShapeIteratorFunction>(d);
65 public static IntPtr ToFunctionPointer(this BodyVelocityFunction d)
72 return Marshal.GetFunctionPointerForDelegate<BodyVelocityFunction>(d);
75 public static IntPtr ToFunctionPointer(this BodyPositionFunction d)
82 return Marshal.GetFunctionPointerForDelegate<BodyPositionFunction>(d);
85 public static IntPtr ToFunctionPointer(this CollisionBeginFunction d)
92 return Marshal.GetFunctionPointerForDelegate<CollisionBeginFunction>(d);
96 public static IntPtr ToFunctionPointer(this CollisionPreSolveFunction d)
103 return Marshal.GetFunctionPointerForDelegate<CollisionPreSolveFunction>(d);
107 public static IntPtr ToFunctionPointer(this CollisionPostSolveFunction d)
114 return Marshal.GetFunctionPointerForDelegate<CollisionPostSolveFunction>(d);
118 public static IntPtr ToFunctionPointer(this CollisionSeparateFunction d)
125 return Marshal.GetFunctionPointerForDelegate<CollisionSeparateFunction>(d);
129 public static IntPtr ToFunctionPointer(this PostStepFunction d)
136 return Marshal.GetFunctionPointerForDelegate<PostStepFunction>(d);
140 public static IntPtr ToFunctionPointer(this SpaceSegmentQueryFunction d)
147 return Marshal.GetFunctionPointerForDelegate<SpaceSegmentQueryFunction>(d);
150 public static IntPtr ToFunctionPointer(this SpacePointQueryFunction d)
157 return Marshal.GetFunctionPointerForDelegate<SpacePointQueryFunction>(d);
160 public static IntPtr ToFunctionPointer(this SpaceBBQueryFunction d)
167 return Marshal.GetFunctionPointerForDelegate<SpaceBBQueryFunction>(d);
171 public static IntPtr ToFunctionPointer(this SpaceObjectIteratorFunction d)
178 return Marshal.GetFunctionPointerForDelegate<SpaceObjectIteratorFunction>(d);
182 public static IntPtr ToFunctionPointer(this SpaceDebugDrawCircleImpl d)
189 return Marshal.GetFunctionPointerForDelegate<SpaceDebugDrawCircleImpl>(d);
193 public static IntPtr ToFunctionPointer(this SpaceDebugDrawSegmentImpl d)
200 return Marshal.GetFunctionPointerForDelegate<SpaceDebugDrawSegmentImpl>(d);
203 public static IntPtr ToFunctionPointer(this SpaceDebugDrawFatSegmentImpl d)
210 return Marshal.GetFunctionPointerForDelegate<SpaceDebugDrawFatSegmentImpl>(d);
213 public static IntPtr ToFunctionPointer(this SpaceDebugDrawPolygonImpl d)
220 return Marshal.GetFunctionPointerForDelegate<SpaceDebugDrawPolygonImpl>(d);
223 public static IntPtr ToFunctionPointer(this SpaceDebugDrawDotImpl d)
230 return Marshal.GetFunctionPointerForDelegate<SpaceDebugDrawDotImpl>(d);
233 public static IntPtr ToFunctionPointer(this SpaceDebugDrawColorForShapeImpl d)
240 return Marshal.GetFunctionPointerForDelegate<SpaceDebugDrawColorForShapeImpl>(d);
244 public static IntPtr ToFunctionPointer(this ConstraintSolveFunction d)
251 return Marshal.GetFunctionPointerForDelegate<ConstraintSolveFunction>(d);
254 public static IntPtr ToFunctionPointer(this DampedSpringForceFunction d)
261 return Marshal.GetFunctionPointerForDelegate<DampedSpringForceFunction>(d);
264 public static IntPtr ToFunctionPointer(this DampedRotarySpringTorqueFunction d)
271 return Marshal.GetFunctionPointerForDelegate<DampedRotarySpringTorqueFunction>(d);
274 public static IntPtr ToFunctionPointer(this SpaceShapeQueryFunction d)
281 return Marshal.GetFunctionPointerForDelegate<SpaceShapeQueryFunction>(d);
284 public static IntPtr ToFunctionPointer(this MarchSegmentFunction d)
291 return Marshal.GetFunctionPointerForDelegate<MarchSegmentFunction>(d);
294 public static IntPtr ToFunctionPointer(this MarchSampleFunction d)
301 return Marshal.GetFunctionPointerForDelegate<MarchSampleFunction>(d);