mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-09 00:13:20 +02:00
2005-01-11 Mike Kestner <mkestner@novell.com>
* glib/Argv.cs : add automatic progname handling. * gdk/Global.custom : kill obsolete warnings by using GLib.Argv. svn path=/trunk/gtk-sharp/; revision=38729
This commit is contained in:
parent
903543cdb4
commit
b6b39dbbfe
@ -1,3 +1,8 @@
|
||||
2005-01-11 Mike Kestner <mkestner@novell.com>
|
||||
|
||||
* glib/Argv.cs : add automatic progname handling.
|
||||
* gdk/Global.custom : kill obsolete warnings by using GLib.Argv.
|
||||
|
||||
2005-01-11 Mike Kestner <mkestner@novell.com>
|
||||
|
||||
* gdk/Gdk.metadata : kill Colors since its methods are deprecated
|
||||
|
@ -73,5 +73,21 @@
|
||||
<remarks />
|
||||
</Docs>
|
||||
</Member>
|
||||
<Member MemberName=".ctor">
|
||||
<MemberSignature Language="C#" Value="public Argv (string [] args, bool add_program_name);" />
|
||||
<MemberType>Constructor</MemberType>
|
||||
<ReturnValue />
|
||||
<Parameters>
|
||||
<Parameter Name="args" Type="System.String[]" />
|
||||
<Parameter Name="add_program_name" Type="System.Boolean" />
|
||||
</Parameters>
|
||||
<Docs>
|
||||
<summary>Public constructor</summary>
|
||||
<param name="args">a <see cref="T:System.String" /></param>
|
||||
<param name="add_program_name">a <see cref="T:System.Boolean" /></param>
|
||||
<returns>a <see cref="T:GLib.Argv" /></returns>
|
||||
<remarks>If <paramref name="add_program_name"/> is <see langword="true"/>, the native argv will also contain a leading string containing the program name reported in the first element of the array returned by <see cref="M:System.Environment.GetCommandLineArgs"/>.</remarks>
|
||||
</Docs>
|
||||
</Member>
|
||||
</Members>
|
||||
</Type>
|
||||
|
@ -141,10 +141,12 @@
|
||||
|
||||
public static bool InitCheck (ref string[] argv)
|
||||
{
|
||||
IntPtr ptr = GLib.Marshaller.ArgvToArrayPtr (argv);
|
||||
int count = argv.Length;
|
||||
bool result = gdk_init_check (ref count, ref ptr);
|
||||
argv = GLib.Marshaller.ArrayPtrToArgv (ptr, count);
|
||||
GLib.Argv a = new GLib.Argv (argv, true);
|
||||
IntPtr buf = a.Handle;
|
||||
int argc = argv.Length + 1;
|
||||
|
||||
bool result = gdk_init_check (ref argc, ref buf);
|
||||
argv = a.GetArgs (argc);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -153,10 +155,12 @@
|
||||
|
||||
public static void ParseArgs (ref string[] argv)
|
||||
{
|
||||
IntPtr ptr = GLib.Marshaller.ArgvToArrayPtr (argv);
|
||||
int count = argv.Length;
|
||||
gdk_parse_args (ref count, ref ptr);
|
||||
argv = GLib.Marshaller.ArrayPtrToArgv (ptr, count);
|
||||
GLib.Argv a = new GLib.Argv (argv, true);
|
||||
IntPtr buf = a.Handle;
|
||||
int argc = argv.Length + 1;
|
||||
|
||||
gdk_parse_args (ref argc, ref buf);
|
||||
argv = a.GetArgs (argc);
|
||||
}
|
||||
|
||||
[DllImport("libgdk-win32-2.0-0.dll")]
|
||||
|
21
glib/Argv.cs
21
glib/Argv.cs
@ -28,6 +28,7 @@ namespace GLib {
|
||||
|
||||
IntPtr[] arg_ptrs;
|
||||
IntPtr handle;
|
||||
bool add_progname = false;
|
||||
|
||||
[DllImport("libglib-2.0-0.dll")]
|
||||
static extern IntPtr g_strdup (string str);
|
||||
@ -46,8 +47,18 @@ namespace GLib {
|
||||
g_free (handle);
|
||||
}
|
||||
|
||||
public Argv (string[] args)
|
||||
public Argv (string[] args) : this (args, false) {}
|
||||
|
||||
public Argv (string[] args, bool add_program_name)
|
||||
{
|
||||
add_progname = add_program_name;
|
||||
if (add_progname) {
|
||||
string[] full = new string [args.Length + 1];
|
||||
full [0] = System.Environment.GetCommandLineArgs ()[0];
|
||||
args.CopyTo (full, 1);
|
||||
args = full;
|
||||
}
|
||||
|
||||
arg_ptrs = new IntPtr [args.Length];
|
||||
|
||||
for (int i = 0; i < args.Length; i++)
|
||||
@ -67,10 +78,12 @@ namespace GLib {
|
||||
|
||||
public string[] GetArgs (int argc)
|
||||
{
|
||||
string[] result = new string [argc];
|
||||
int count = add_progname ? argc - 1 : argc;
|
||||
int idx = add_progname ? 1 : 0;
|
||||
string[] result = new string [count];
|
||||
|
||||
for (int i = 0; i < argc; i++)
|
||||
result [i] = Marshal.PtrToStringAnsi (Marshal.ReadIntPtr (handle, i * IntPtr.Size));
|
||||
for (int i = 0; i < count; i++, idx++)
|
||||
result [i] = Marshal.PtrToStringAnsi (Marshal.ReadIntPtr (handle, idx * IntPtr.Size));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user