Skip to content

Commit 486598d

Browse files
committed
Projektdateien hinzufügen.
1 parent a4218a0 commit 486598d

36 files changed

+11830
-0
lines changed

AMX.cs

Lines changed: 781 additions & 0 deletions
Large diffs are not rendered by default.

AMXArgumentList.cs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// AMXWrapper for .NET Core
2+
// Copyright 2015-2023 Tim Potze and ported to .NET Core by github.com/michael-fa
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
using System;
17+
using System.Runtime.InteropServices;
18+
19+
namespace AMXWrapperCore
20+
{
21+
/// <summary>
22+
/// Represents an function arguments list.
23+
/// </summary>
24+
[StructLayout(LayoutKind.Sequential)]
25+
public struct AMXArgumentList
26+
{
27+
private readonly IntPtr _ptr;
28+
29+
/// <summary>
30+
/// Initializes a new instance of the <see cref="AMXArgumentList"/> struct.
31+
/// </summary>
32+
/// <param name="ptr">A pointer to the list.</param>
33+
public AMXArgumentList(IntPtr ptr)
34+
{
35+
_ptr = ptr;
36+
}
37+
38+
/// <summary>
39+
/// Gets the length.
40+
/// </summary>
41+
public int Length
42+
{
43+
get { return Marshal.ReadInt32(_ptr)/Marshal.SizeOf(typeof (Cell)); }
44+
}
45+
46+
/// <summary>
47+
/// Gets the <see cref="Cell"/> at the specified 0-based index.
48+
/// </summary>
49+
/// <value>
50+
/// The <see cref="Cell"/>.
51+
/// </value>
52+
/// <param name="index">The index.</param>
53+
/// <returns></returns>
54+
public Cell this[int index]
55+
{
56+
get { return Cell.FromIntPtr(IntPtr.Add(_ptr, (index + 1)*Marshal.SizeOf(typeof (Cell)))); }
57+
}
58+
}
59+
}

AMXCall.cs

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
// AMXWrapper for .NET Core
2+
// Copyright 2015-2023 Tim Potze and ported to .NET Core by github.com/michael-fa
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
using System;
17+
using System.Runtime.InteropServices;
18+
using System.Text;
19+
20+
namespace AMXWrapperCore
21+
{
22+
internal static class AMXCall
23+
{
24+
private const string Library = "amx32.dll";
25+
26+
27+
[DllImport(Library, EntryPoint = "amx_Flags")]
28+
public static extern int Flags(ref AMXStruct amx, out UInt16 flags);
29+
30+
//[DllImport(library, EntryPoint = "amx_Callback")]
31+
//public static extern int Callback(ref AMXStruct amx, int index, IntPtr result, AMXArgumentList parms);
32+
33+
[DllImport(Library, EntryPoint = "amx_Init")]
34+
public static extern int Init(ref AMXStruct amx, IntPtr program);
35+
36+
[DllImport(Library, EntryPoint = "amx_Cleanup")]
37+
public static extern int Cleanup(ref AMXStruct amx);
38+
39+
[DllImport(Library, EntryPoint = "amx_Clone")]
40+
public static extern int Clone(ref AMXStruct amxClone, AMXStruct amxSource, IntPtr data);
41+
42+
[DllImport(Library, EntryPoint = "amx_MemInfo")]
43+
public static extern int MemoryInfo(ref AMXStruct amx, out long codesize, out long datasize, out long stackheap);
44+
45+
[DllImport(Library, EntryPoint = "amx_NameLength")]
46+
public static extern int NameLength(ref AMXStruct amx, out int length);
47+
48+
[DllImport(Library, EntryPoint = "amx_NumNatives")]
49+
public static extern int NumberOfNatives(ref AMXStruct amx, out int number);
50+
51+
[DllImport(Library, EntryPoint = "amx_GetNative")]
52+
public static extern int GetNative(ref AMXStruct amx, int index, StringBuilder name);
53+
54+
[DllImport(Library, EntryPoint = "amx_FindNative")]
55+
public static extern int FindNative(ref AMXStruct amx, string name, out int index);
56+
57+
[DllImport(Library, EntryPoint = "amx_NumPublics")]
58+
public static extern int NumberOfPublics(ref AMXStruct amx, out int number);
59+
60+
[DllImport(Library, EntryPoint = "amx_GetPublic")]
61+
public static extern int GetPublic(ref AMXStruct amx, int index, StringBuilder name, out IntPtr address);
62+
63+
[DllImport(Library, EntryPoint = "amx_FindPublic")]
64+
public static extern int FindPublic(ref AMXStruct amx, string name, out int index);
65+
66+
[DllImport(Library, EntryPoint = "amx_NumPubVars")]
67+
public static extern int NumberOfPublicVars(ref AMXStruct amx, out int number);
68+
69+
[DllImport(Library, EntryPoint = "amx_GetPubVar")]
70+
public static extern int GetPublicVar(ref AMXStruct amx, int index, StringBuilder name, out IntPtr address);
71+
72+
[DllImport(Library, EntryPoint = "amx_FindPubVar")]
73+
public static extern int FindPublicVar(ref AMXStruct amx, string name, out IntPtr address);
74+
75+
[DllImport(Library, EntryPoint = "amx_NumTags")]
76+
public static extern int NumberOfTags(ref AMXStruct amx, out int number);
77+
78+
[DllImport(Library, EntryPoint = "amx_GetTag")]
79+
public static extern int GetTag(ref AMXStruct amx, int index, StringBuilder tagname, out Int32 tagID);
80+
81+
[DllImport(Library, EntryPoint = "amx_FindTagId")]
82+
public static extern int FindTagId(ref AMXStruct amx, Int32 tagID, StringBuilder tagname);
83+
84+
//private static extern int amx_GetUserData(ref AMX amx, long tag, void **ptr);
85+
86+
//private static extern int amx_SetUserData(ref AMX amx, long tag, void *ptr);
87+
88+
[DllImport(Library, EntryPoint = "amx_Register")]
89+
public static extern int Register(ref AMXStruct amx, [MarshalAs(UnmanagedType.LPArray)] AMXNativeInfo[] list,
90+
int count);
91+
92+
[DllImport(Library, EntryPoint = "amx_Push")]
93+
public static extern int Push(ref AMXStruct amx, Int32 value);
94+
95+
[DllImport(Library, EntryPoint = "amx_PushAddress")]
96+
public static extern int PushAddress(ref AMXStruct amx, IntPtr address);
97+
98+
[DllImport(Library, EntryPoint = "amx_PushAddress")]
99+
public static extern int PushAddress(ref AMXStruct amx, ref Cell cell);
100+
101+
[DllImport(Library, EntryPoint = "amx_PushArray")]
102+
public static extern int PushArray(ref AMXStruct amx, out CellPtr address, int[] array, int numcells);
103+
104+
[DllImport(Library, EntryPoint = "amx_PushString")]
105+
public static extern int PushString(ref AMXStruct amx, out IntPtr address, string str, int pack, int useWchar);
106+
107+
[DllImport(Library, EntryPoint = "amx_Exec")]
108+
public static extern int Exec(ref AMXStruct amx, out int retval, int index);
109+
110+
//[DllImport(library, EntryPoint = "amx_SetCallback")]
111+
//private static extern int AmxSetCallback(ref AMXStruct amx, AmxCallback callback);
112+
113+
//[DllImport(library, EntryPoint = "amx_SetDebugHook")]
114+
//private static extern int AmxSetDebugHook(ref AMX amx,AmxDebug debug);
115+
116+
[DllImport(Library, EntryPoint = "amx_RaiseError")]
117+
public static extern int RaiseError(ref AMXStruct amx, int error);
118+
119+
[DllImport(Library, EntryPoint = "amx_Allot")]
120+
public static extern int Allot(ref AMXStruct amx, int cells, out IntPtr address);
121+
122+
[DllImport(Library, EntryPoint = "amx_Release")]
123+
public static extern int Release(ref AMXStruct amx, IntPtr address);
124+
125+
[DllImport(Library, EntryPoint = "amx_StrLen")]
126+
public static extern int StrLen(IntPtr cstr, out int length);
127+
128+
[DllImport(Library, EntryPoint = "amx_SetString")]
129+
public static extern int SetString(IntPtr dest, string source, int pack, int useWchar, int size);
130+
131+
[DllImport(Library, EntryPoint = "amx_GetString")]
132+
public static extern int GetString(StringBuilder dest, IntPtr source, int useWchar, int size);
133+
134+
//public static extern int amx_UTF8Get(const char *string, const char **endptr, cell *value)
135+
136+
//public static extern int amx_UTF8Put(char *string, char **endptr, int maxchars, cell value)
137+
138+
//public static extern int amx_UTF8Check(const char *string, int *length)
139+
140+
//public static extern int amx_UTF8Len(const cell *cstr, int *length)
141+
142+
143+
[DllImport(Library, EntryPoint = "amx_ConsoleInit")]
144+
public static extern int ConsoleInit(ref AMXStruct amx);
145+
146+
[DllImport(Library, EntryPoint = "amx_ConsoleCleanup")]
147+
public static extern int ConsoleCleanup(ref AMXStruct amx);
148+
149+
[DllImport(Library, EntryPoint = "amx_CoreInit")]
150+
public static extern int CoreInit(ref AMXStruct amx);
151+
152+
[DllImport(Library, EntryPoint = "amx_CoreCleanup")]
153+
public static extern int CoreCleanup(ref AMXStruct amx);
154+
155+
[DllImport(Library, EntryPoint = "amx_DGramInit")]
156+
public static extern int DGramInit(ref AMXStruct amx);
157+
158+
[DllImport(Library, EntryPoint = "amx_DGramCleanup")]
159+
public static extern int DGramCleanup(ref AMXStruct amx);
160+
161+
[DllImport(Library, EntryPoint = "amx_StringInit")]
162+
public static extern int StringInit(ref AMXStruct amx);
163+
164+
[DllImport(Library, EntryPoint = "amx_StringCleanup")]
165+
public static extern int StringCleanup(ref AMXStruct amx);
166+
167+
[DllImport(Library, EntryPoint = "amx_TimeInit")]
168+
public static extern int TimeInit(ref AMXStruct amx);
169+
170+
[DllImport(Library, EntryPoint = "amx_TimeCleanup")]
171+
public static extern int TimeClean(ref AMXStruct amx);
172+
173+
[DllImport(Library, EntryPoint = "amx_FixedInit")]
174+
public static extern int FixedInit(ref AMXStruct amx);
175+
176+
[DllImport(Library, EntryPoint = "amx_FixedCleanup")]
177+
public static extern int FixedCleanup(ref AMXStruct amx);
178+
179+
[DllImport(Library, EntryPoint = "amx_FloatInit")]
180+
public static extern int FloatInit(ref AMXStruct amx);
181+
182+
[DllImport(Library, EntryPoint = "amx_FloatCleanup")]
183+
public static extern int FloatCleanup(ref AMXStruct amx);
184+
185+
186+
}
187+
}

AMXDefaultLibrary.cs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// AMXWrapper for .NET Core
2+
// Copyright 2015-2023 Tim Potze and ported to .NET Core by github.com/michael-fa
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
using System;
17+
18+
namespace AMXWrapperCore
19+
{
20+
/// <summary>
21+
/// Contains all libraries provided by amx32.
22+
/// </summary>
23+
[Flags]
24+
public enum AMXDefaultLibrary
25+
{
26+
/// <summary>
27+
/// No library.
28+
/// </summary>
29+
None,
30+
31+
/// <summary>
32+
/// The console library.
33+
/// </summary>
34+
Console,
35+
36+
/// <summary>
37+
/// The core library.
38+
/// </summary>
39+
Core,
40+
41+
/// <summary>
42+
/// The d gram library.
43+
/// </summary>
44+
DGram,
45+
46+
/// <summary>
47+
/// The string library.
48+
/// </summary>
49+
String,
50+
51+
/// <summary>
52+
/// The time library.
53+
/// </summary>
54+
Time,
55+
56+
/// <summary>
57+
/// The fixed library.
58+
/// </summary>
59+
Fixed,
60+
61+
/// <summary>
62+
/// The float library.
63+
/// </summary>
64+
Float,
65+
}
66+
}

0 commit comments

Comments
 (0)