File: girctypesmapping.pas

package info (click to toggle)
gir2pas 0.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 732 kB
  • sloc: pascal: 7,033; makefile: 59
file content (93 lines) | stat: -rw-r--r-- 3,530 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
{
ctypesmapping.pas
Copyright (C) 2011  Andrew Haines andrewd207@aol.com

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

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, see <https://www.gnu.org/licenses/>.
}
unit girCTypesMapping;

{$mode objfpc}{$H+}

interface

type
  TGType = record
    CType: string;
    PType: string;
  end;

var
  GTypes: array of TGType = (
    (CType: 'void';                     PType: 'void'),
    (CType: 'gpointer';                 PType: 'pointer'),
    (CType: 'int';                      PType: 'cint'),
    (CType: 'gint';                     PType: 'cint'),
    (CType: 'guint';                    PType: 'cuint'),
    (CType: 'guint8';                   PType: 'cuint8'),
    (CType: 'guint16';                  PType: 'cuint16'),
    (CType: 'guint32';                  PType: 'cuint32'),
    (CType: 'guint64';                  PType: 'cuint64'),
    (CType: 'gint8';                    PType: 'cint8'),
    (CType: 'gint16';                   PType: 'cint16'),
    (CType: 'gint32';                   PType: 'cint32'),
    (CType: 'gint64';                   PType: 'cint64'),
    (CType: 'gsize';                    PType: 'csize_t'),
    (CType: 'glong';                    PType: 'clong'),
    (CType: 'gulong';                   PType: 'culong'),
    (CType: 'gushort';                  PType: 'cushort'),
    (CType: 'gshort';                   PType: 'cshort'),
    (CType: 'gchar';                    PType: 'char'),
    (CType: 'guchar';                   PType: 'byte'),
    (CType: 'gboolean';                 PType: 'Boolean32'),
    (CType: 'gssize';                   PType: 'PtrInt'),
    (CType: 'int32';                    PType: 'cint32'),
    (CType: 'size_t' ;                  PType: 'csize_t'),
    (CType: 'gconstpointer';            PType: 'gpointer'),
    (CType: 'gfloat';                   PType: 'cfloat'),
    (CType: 'gdouble';                  PType: 'cdouble'),
    (CType: 'double';                   PType: 'cdouble'),
    (CType: 'char';                     PType: 'char'),
    (CType: 'goffset';                  PType: 'Int64'),
    (CType: 'long double';              PType: 'Extended'),
    (CType: 'gunichar';                 PType: 'guint32'),
    (CType: 'gunichar2';                PType: 'guint32'),
    (CType: 'file';                     PType: 'file'),
    (CType: 'pid_t';                    PType: 'cint32'),
    (CType: 'time_t';                   PType: 'cint64'),
    (CType: 'uid_t';                    PType: 'cuint32'),
    (CType: 'unsigned long long';       PType: 'qword'),
    (CType: 'TGType';                   PType: 'gsize'),
	{Keep GType always at last position.}
    (CType: 'GType';                    PType: 'TGType')
  );

  function LookupGTypeToCType(AName: String): String;



implementation

function LookupGTypeToCType(AName: String): String;
var
  i: Integer;
begin
  //WriteLn('Looking up: ', AName);
  for i := Low(GTypes) to High(GTypes) do
    if AName = GTypes[i].CType then
      Exit(GTypes[i].PType);
  Result := '';
end;

end.