From 7dbea0aa67b73bc0d16b5468667efbbd364d2345 Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Wed, 17 Nov 2004 16:00:00 +0000 Subject: [PATCH] 2004-11-17 Mike Kestner * generator/Makefile.am : add new file. * generator/Method.cs : refactoring to use ReturnValue. * generator/MethodBody.cs : remove unnecessary code. * generator/ReturnValue.cs : class for redundant retval handling. * generator/Signal.cs : refactoring for ReturnValue. * generator/SignalHandler.cs : refactoring for ReturnValue. svn path=/trunk/gtk-sharp/; revision=36219 --- generator/ReturnValue.cs | 82 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 generator/ReturnValue.cs diff --git a/generator/ReturnValue.cs b/generator/ReturnValue.cs new file mode 100644 index 000000000..035deda1e --- /dev/null +++ b/generator/ReturnValue.cs @@ -0,0 +1,82 @@ +// GtkSharp.Generation.ReturnValue.cs - The ReturnValue Generatable. +// +// Author: Mike Kestner +// +// Copyright (c) 2004 Novell, Inc. +// +// 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. + + +namespace GtkSharp.Generation { + + using System; + using System.Xml; + + public class ReturnValue { + + private XmlElement elem; + + public ReturnValue (XmlElement elem) + { + this.elem = elem; + } + + public string CType { + get { + return elem == null ? String.Empty : elem.GetAttribute("type"); + } + } + + public string CSType { + get { + return SymbolTable.Table.GetCSType (CType) + (IsArray ? "[]" : String.Empty); + } + } + + public string ElementType { + get { + return elem == null ? String.Empty : elem.GetAttribute("element_type"); + } + } + + public bool IsArray { + get { + return elem == null ? false : elem.HasAttribute ("array"); + } + } + + public string MarshalType { + get { + return SymbolTable.Table.GetMarshalReturnType (CType) + (IsArray ? "[]" : String.Empty); + } + } + + public string ToNativeType { + get { + return SymbolTable.Table.GetMarshalType (CType) + (IsArray ? "[]" : String.Empty); + } + } + + public bool Validate () + { + if (MarshalType == "" || CSType == "") { + Console.Write("rettype: " + CType); + return false; + } + return true; + } + } +} +