2004-04-12 15:54:57 +00:00
|
|
|
// GtkSharp.Generation.ByRefGen.cs - The ByRef type Generatable.
|
|
|
|
//
|
2004-12-26 21:22:50 +00:00
|
|
|
// Author: Mike Kestner <mkestner@novell.com>
|
2004-04-12 15:54:57 +00:00
|
|
|
//
|
2004-06-25 16:35:15 +00:00
|
|
|
// Copyright (c) 2003 Mike Kestner
|
2004-12-26 21:22:50 +00:00
|
|
|
// Copyright (c) 2004 Novell, Inc.
|
2004-06-25 16:35:15 +00:00
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of version 2 of the GNU General Public
|
|
|
|
// License as published by the Free Software Foundation.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public
|
|
|
|
// License along with this program; if not, write to the
|
|
|
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
// Boston, MA 02111-1307, USA.
|
|
|
|
|
2004-04-12 15:54:57 +00:00
|
|
|
|
|
|
|
namespace GtkSharp.Generation {
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
2007-08-13 17:48:24 +00:00
|
|
|
public class ByRefGen : SimpleBase, IManualMarshaler {
|
2004-04-12 15:54:57 +00:00
|
|
|
|
2007-09-21 16:37:04 +00:00
|
|
|
public ByRefGen (string ctype, string type) : base (ctype, type, type + ".Empty") {}
|
2004-04-12 15:54:57 +00:00
|
|
|
|
2004-12-26 21:22:50 +00:00
|
|
|
public override string MarshalType {
|
|
|
|
get {
|
2007-08-13 17:48:24 +00:00
|
|
|
return "IntPtr";
|
2004-04-12 15:54:57 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-18 22:19:31 +00:00
|
|
|
|
2007-08-13 17:48:24 +00:00
|
|
|
public override string CallByName (string var_name)
|
|
|
|
{
|
|
|
|
return "native_" + var_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public string AllocNative ()
|
|
|
|
{
|
|
|
|
return "Marshal.AllocHGlobal (Marshal.SizeOf (typeof (" + QualifiedName + ")))";
|
2004-04-12 15:54:57 +00:00
|
|
|
}
|
|
|
|
|
2007-08-13 17:48:24 +00:00
|
|
|
public string AllocNative (string var_name)
|
|
|
|
{
|
|
|
|
return "GLib.Marshaller.StructureToPtrAlloc (" + var_name + ")";
|
2004-11-18 22:19:31 +00:00
|
|
|
}
|
|
|
|
|
2007-08-13 17:48:24 +00:00
|
|
|
public override string FromNative (string var_name)
|
2004-04-12 15:54:57 +00:00
|
|
|
{
|
2007-08-13 17:48:24 +00:00
|
|
|
return String.Format ("({0}) Marshal.PtrToStructure ({1}, typeof ({0}))", QualifiedName, var_name);
|
2004-04-12 15:54:57 +00:00
|
|
|
}
|
2007-08-13 17:48:24 +00:00
|
|
|
|
|
|
|
public string ReleaseNative (string var_name)
|
2004-04-12 15:54:57 +00:00
|
|
|
{
|
2007-08-13 17:48:24 +00:00
|
|
|
return "GLib.Marshaller.Free (" + var_name + ")";
|
2004-04-12 15:54:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|