~ubuntu-branches/ubuntu/lucid/docky/lucid-proposed

« back to all changes in this revision

Viewing changes to lib/gio-sharp/generator/SimpleBase.cs

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2010-02-17 15:10:07 UTC
  • Revision ID: james.westby@ubuntu.com-20100217151007-msxpd0lsj300ndde
Tags: upstream-2.0.0
ImportĀ upstreamĀ versionĀ 2.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// GtkSharp.Generation.SimpleBase.cs - base class for marshaling non-generated types.
 
2
//
 
3
// Author: Mike Kestner <mkestner@novell.com>
 
4
//
 
5
// Copyright (c) 2004 Novell, Inc.
 
6
//
 
7
// This program is free software; you can redistribute it and/or
 
8
// modify it under the terms of version 2 of the GNU General Public
 
9
// License as published by the Free Software Foundation.
 
10
//
 
11
// This program is distributed in the hope that it will be useful,
 
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
// General Public License for more details.
 
15
//
 
16
// You should have received a copy of the GNU General Public
 
17
// License along with this program; if not, write to the
 
18
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
19
// Boston, MA 02111-1307, USA.
 
20
 
 
21
 
 
22
namespace GtkSharp.Generation {
 
23
 
 
24
        using System;
 
25
 
 
26
        public abstract class SimpleBase : IGeneratable  {
 
27
                
 
28
                string type;
 
29
                string ctype;
 
30
                string ns = String.Empty;
 
31
                string default_value = String.Empty;
 
32
 
 
33
                public SimpleBase (string ctype, string type, string default_value)
 
34
                {
 
35
                        string[] toks = type.Split('.');
 
36
                        this.ctype = ctype;
 
37
                        this.type = toks[toks.Length - 1];
 
38
                        if (toks.Length > 2)
 
39
                                this.ns = String.Join (".", toks, 0, toks.Length - 1);
 
40
                        else if (toks.Length == 2)
 
41
                                this.ns = toks[0];
 
42
                        this.default_value = default_value;
 
43
                }
 
44
                
 
45
                public string CName {
 
46
                        get {
 
47
                                return ctype;
 
48
                        }
 
49
                }
 
50
 
 
51
                public string Name {
 
52
                        get {
 
53
                                return type;
 
54
                        }
 
55
                }
 
56
 
 
57
                public string QualifiedName {
 
58
                        get {
 
59
                                return ns == String.Empty ? type : ns + "." + type;
 
60
                        }
 
61
                }
 
62
 
 
63
                public virtual string MarshalType {
 
64
                        get {
 
65
                                return QualifiedName;
 
66
                        }
 
67
                }
 
68
 
 
69
                public virtual string MarshalReturnType {
 
70
                        get {
 
71
                                return MarshalType;
 
72
                        }
 
73
                }
 
74
 
 
75
                public virtual string DefaultValue {
 
76
                        get {
 
77
                                return default_value;
 
78
                        }
 
79
                }
 
80
 
 
81
                public virtual string ToNativeReturnType {
 
82
                        get {
 
83
                                return MarshalType;
 
84
                        }
 
85
                }
 
86
 
 
87
                public virtual string CallByName (string var)
 
88
                {
 
89
                        return var;
 
90
                }
 
91
                
 
92
                public virtual string FromNative(string var)
 
93
                {
 
94
                        return var;
 
95
                }
 
96
                
 
97
                public virtual string FromNativeReturn(string var)
 
98
                {
 
99
                        return FromNative (var);
 
100
                }
 
101
 
 
102
                public virtual string ToNativeReturn(string var)
 
103
                {
 
104
                        return CallByName (var);
 
105
                }
 
106
 
 
107
                public bool Validate ()
 
108
                {
 
109
                        return true;
 
110
                }
 
111
 
 
112
                public void Generate ()
 
113
                {
 
114
                }
 
115
                
 
116
                public void Generate (GenerationInfo gen_info)
 
117
                {
 
118
                }
 
119
        }
 
120
}
 
121