aboutsummaryrefslogtreecommitdiffstats
path: root/bindings/clx/Sword.pas
blob: 9fecc17d3a706be1bafc8ab1d7312fa83feffcd2 (plain) (blame)
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
unit Sword;

   
interface
   const LIBNAME = 'sword.dll';
   function  SWMgr_getPrefixPath(h: integer): PChar; cdecl; external libname;
   function  SWMgr_new: integer; cdecl; external LIBNAME;
   procedure SWMgr_delete(h: integer); cdecl; external LIBNAME;
   function  SWMgr_getModulesIterator(h: integer) : integer; cdecl; external LIBNAME;
   function  SWMgr_getModuleByName(h: integer; name: PChar) : integer; cdecl; external LIBNAME;

   procedure ModList_iterator_next(h: integer); cdecl; external LIBNAME;
   function  ModList_iterator_val(h: integer) : integer; cdecl; external LIBNAME;

   function  SWModule_getType(h: integer) : PChar; cdecl; external LIBNAME;
   function  SWModule_getName(h: integer) : PChar; cdecl; external LIBNAME;
   function  SWModule_getDescription(h: integer) : PChar; cdecl; external LIBNAME;
   function  SWModule_getStripText(h: integer) : PChar; cdecl; external LIBNAME;
   function  SWModule_getRenderText(h: integer) : PChar; cdecl; external LIBNAME;
   function  SWModule_getKeyText(h: integer) : PChar; cdecl; external LIBNAME;
   procedure SWModule_setKeyText(h: integer; key: PChar); cdecl; external LIBNAME;
   procedure SWModule_begin(h: integer); cdecl; external LIBNAME;
   procedure SWModule_next(h: integer); cdecl; external LIBNAME;
   procedure SWModule_previous(h: integer); cdecl; external LIBNAME;
type

   SWModule = class(TObject)
   private
      handle : integer;
   public
      constructor Create(handle : integer);
      function getType : String;
      function getName : String;
      function getDescription : String;
      function getStripText : String;                
      function getRenderText : WideString;                
      function getKeyText : String;                
      procedure setKeyText(keyText : String);
      procedure modBegin;
      procedure modNext;
      procedure modPrevious;
   end;

   
   ModIterator = class(TObject)
   private
      handle : integer;
   public
      constructor Create(handle : integer);
      procedure next;
      function getValue : SWModule;
   end;
  

   SWMgr = class(TObject)
   private
      handle : integer;
   public
      constructor Create;
      destructor Destroy; override;
      function getPrefixPath : String;
      function getModulesIterator : ModIterator;
      function getModuleByName(name: String) : SWModule;
  end;

implementation

constructor SWMgr.Create;
var
   yohan : integer;
begin
   yohan := SWMgr_new;
   handle := yohan;
end;


destructor SWMgr.Destroy;
begin
   SWMgr_delete(handle);
end;


function SWMgr.getPrefixPath() : String;
var
   stuff : String;
   pstuff : PChar;
begin
   pstuff := SWMgr_getPrefixPath(handle);
   stuff := String(pstuff);
   Result := stuff;
end;


function SWMgr.getModulesIterator : ModIterator;
begin
   Result := ModIterator.Create(SWMgr_getModulesIterator(handle));
end;

function SWMgr.getModuleByName(name: String) : SWModule;
var
   modHandle : Integer;
   
begin
   modHandle := SWMgr_getModuleByName(handle, PChar(name));
   if (modHandle <> 0) then
      Result := SWModule.Create(modHandle)
   else Result := nil;
end;




{ ModIterator methods --------------------------------------------- }


constructor ModIterator.Create(handle : integer);
begin
   Self.handle := handle;
end;


procedure ModIterator.next;
begin
   ModList_iterator_next(handle);
end;


function ModIterator.getValue : SWModule;
var
   modHandle : Integer;
   
begin
   modHandle := ModList_iterator_val(handle);
   if (modHandle <> 0) then
      Result := SWModule.Create(modHandle)
   else Result := nil;
end;





{ SWModule methods --------------------------------------------- }


constructor SWModule.Create(handle : integer);
begin
   Self.handle := handle;
end;


function SWModule.getType : String;
begin
   Result := String(SWModule_getType(handle));
end;


function SWModule.getName : String;
begin
   Result := String(SWModule_getName(handle));
end;


function SWModule.getDescription : String;
begin
   Result := String(SWModule_getDescription(handle));
end;


function SWModule.getStripText : String;
begin
   Result := String(SWModule_getStripText(handle));
end;


function SWModule.getRenderText : WideString;
begin
   Result := WideString(SWModule_getRenderText(handle));
end;


function SWModule.getKeyText : String;
begin
   Result := String(SWModule_getKeyText(handle));
end;


procedure SWModule.setKeyText(keyText: String);
begin
   SWModule_setKeyText(handle, PChar(keyText));
end;


procedure SWModule.modBegin;
begin
   SWModule_begin(handle);
end; 


procedure SWModule.modNext;
begin
   SWModule_next(handle);
end; 


procedure SWModule.modPrevious;
begin
   SWModule_previous(handle);
end;

end.