Merge lp:~smspillaz/compiz-libcompizconfig/context-funcs-behind-interface into lp:~compiz-team/compiz-libcompizconfig/0.9.8
- context-funcs-behind-interface
- Merge into 0.9.8
Status: | Superseded |
---|---|
Proposed branch: | lp:~smspillaz/compiz-libcompizconfig/context-funcs-behind-interface |
Merge into: | lp:~compiz-team/compiz-libcompizconfig/0.9.8 |
Prerequisite: | lp:~smspillaz/compiz-libcompizconfig/refactor-context |
Diff against target: |
855 lines (+333/-87) 4 files modified
include/ccs.h (+55/-5) src/ccs-private.h (+4/-2) src/compiz.cpp (+14/-2) src/main.c (+260/-78) |
To merge this branch: | bzr merge lp:~smspillaz/compiz-libcompizconfig/context-funcs-behind-interface |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alan Griffiths | Needs Fixing | ||
Review via email: mp+104807@code.launchpad.net |
This proposal supersedes a proposal from 2012-04-29.
Commit message
Description of the change
This is all about bug 990690.
!! - It probably isn't a good idea to test this branch in isolation, as it is part of a pipeline to get compiz-
lp:~smspillaz/compiz-libcompizconfig/setting-mock
lp:~smspillaz/compiz-compizconfig-python/compiz-compizconfig-python.setting-api
lp:~smspillaz/compiz-compizconfig-gconf/compiz-compizconfig-gconf.adapt-to-new-interfaces
.. that's all !!
This branch converts the context object to use the base object in its implementation and indirects all of the context object's api through an interface.
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal | # |
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal | # |
> GET_INTERFACE seems overcomplicated and error prone. It requires the first
> two parameters to match up - when in every use the second is a second macro
> with no other use that calls a third with the first parameter. Confused?
>
> Current usage: GET_INTERFACE (CCSContextInte
> context))
> Suggest usage: GET_INTERFACE (CCSContextInte
>
>
> Current #define GET_INTERFACE(
> ((CCSObject *) o, IType)
> Suggest #define GET_INTERFACE(
> (CType*
>
> And get rid of CCS_CONTEXT_
I'm a bit confused - how would GET_INTERFACE_
- 448. By Sam Spilsbury
-
Merged refactor-context into context-
funcs-behind- interface. - 449. By Sam Spilsbury
-
Merged refactor-context into context-
funcs-behind- interface. - 450. By Sam Spilsbury
-
Merge
- 451. By Sam Spilsbury
-
Merged refactor-context into context-
funcs-behind- interface.
Alan Griffiths (alan-griffiths) wrote : | # |
Looks basically OK, but there are merge conflicts with pre-requisites
Sam Spilsbury (smspillaz) wrote : | # |
The conflicts seem to be gone now
- 452. By Sam Spilsbury
-
Move null check
Unmerged revisions
- 452. By Sam Spilsbury
-
Move null check
- 451. By Sam Spilsbury
-
Merged refactor-context into context-
funcs-behind- interface. - 450. By Sam Spilsbury
-
Merge
- 449. By Sam Spilsbury
-
Merged refactor-context into context-
funcs-behind- interface. - 448. By Sam Spilsbury
-
Merged refactor-context into context-
funcs-behind- interface. - 447. By Sam Spilsbury
-
Merged refactor-context into context-
funcs-behind- interface. - 446. By Sam Spilsbury
-
Remove usage #define
- 445. By Sam Spilsbury
-
Simplify dynamic context interface
- 444. By Sam Spilsbury
-
Make it work with the new API
- 443. By Sam Spilsbury
-
Merged refactor-context into context-
funcs-behind- interface.
Preview Diff
1 | === modified file 'include/ccs.h' |
2 | --- include/ccs.h 2012-05-07 14:58:24 +0000 |
3 | +++ include/ccs.h 2012-05-07 14:58:24 +0000 |
4 | @@ -223,6 +223,8 @@ |
5 | return type_id; \ |
6 | } |
7 | |
8 | +#define GET_INTERFACE(CType, o) (CType *) ccsObjectGetInterface (o, GET_INTERFACE_TYPE(CType)) |
9 | + |
10 | /** |
11 | * reference counting |
12 | * |
13 | @@ -273,6 +275,31 @@ |
14 | typedef CCSSettingList (*CCSContextStealChangedSettings) (CCSContext *context); |
15 | typedef void * (*CCSContextGetPrivatePtr) (CCSContext *context); |
16 | typedef void (*CCSContextSetPrivatePtr) (CCSContext *context, void *ptr); |
17 | +typedef Bool (*CCSContextLoadPlugin) (CCSContext *context, char *name); |
18 | +typedef CCSPlugin * (*CCSContextFindPlugin) (CCSContext *context, const char *name); |
19 | +typedef Bool (*CCSContextPluginIsActive) (CCSContext *context, char *name); |
20 | +typedef CCSPluginList (*CCSContextGetActivePluginList) (CCSContext *context); |
21 | +typedef CCSStringList (*CCSContextGetSortedPluginStringList) (CCSContext *context); |
22 | +typedef Bool (*CCSContextSetBackend) (CCSContext *context, char *name); |
23 | +typedef char * (*CCSContextGetBackend) (CCSContext *context); |
24 | +typedef void (*CCSContextSetIntegrationEnabled) (CCSContext *context, Bool value); |
25 | +typedef void (*CCSContextSetProfile) (CCSContext *context, char *name); |
26 | +typedef void (*CCSContextSetPluginListAutoSort) (CCSContext *context, Bool value); |
27 | +typedef char * (*CCSContextGetProfile) (CCSContext *context); |
28 | +typedef Bool (*CCSContextGetIntegrationEnabled) (CCSContext *context); |
29 | +typedef Bool (*CCSContextGetPluginListAutoSort) (CCSContext *context); |
30 | +typedef void (*CCSContextProcessEvents) (CCSContext *context, unsigned int flags); |
31 | +typedef void (*CCSContextReadSettings) (CCSContext *context); |
32 | +typedef void (*CCSContextWriteSettings) (CCSContext *context); |
33 | +typedef void (*CCSContextWriteChangedSettings) (CCSContext *context); |
34 | +typedef Bool (*CCSContextExportToFile) (CCSContext *context, const char *fileName, Bool skipDefaults); |
35 | +typedef Bool (*CCSContextImportFromFile) (CCSContext *context, const char *fileName, Bool overwriteNonDefault); |
36 | +typedef CCSPluginConflictList (*CCSContextCanEnablePlugin) (CCSContext *context, CCSPlugin *plugin); |
37 | +typedef CCSPluginConflictList (*CCSContextCanDisablePlugin) (CCSContext *context, CCSPlugin *plugin); |
38 | +typedef CCSStringList (*CCSContextGetExistingProfiles) (CCSContext *context); |
39 | +typedef void (*CCSContextDeleteProfile) (CCSContext *context, char *name); |
40 | +typedef Bool (*CCSContextCheckForSettingsUpgrade) (CCSContext *context); |
41 | +typedef void (*CCSContextLoadPlugins) (CCSContext *context); |
42 | |
43 | struct _CCSContextInterface |
44 | { |
45 | @@ -285,8 +312,35 @@ |
46 | CCSContextStealChangedSettings contextStealChangedSettings; |
47 | CCSContextGetPrivatePtr contextGetPrivatePtr; |
48 | CCSContextSetPrivatePtr contextSetPrivatePtr; |
49 | + CCSContextLoadPlugin contextLoadPlugin; |
50 | + CCSContextFindPlugin contextFindPlugin; |
51 | + CCSContextPluginIsActive contextPluginIsActive; |
52 | + CCSContextGetActivePluginList contextGetActivePluginList; |
53 | + CCSContextGetSortedPluginStringList contextGetSortedPluginStringList; |
54 | + CCSContextSetBackend contextSetBackend; |
55 | + CCSContextGetBackend contextGetBackend; |
56 | + CCSContextSetIntegrationEnabled contextSetIntegrationEnabled; |
57 | + CCSContextSetProfile contextSetProfile; |
58 | + CCSContextSetPluginListAutoSort contextSetPluginListAutoSort; |
59 | + CCSContextGetProfile contextGetProfile; |
60 | + CCSContextGetIntegrationEnabled contextGetIntegrationEnabled; |
61 | + CCSContextGetPluginListAutoSort contextGetPluginListAutoSort; |
62 | + CCSContextProcessEvents contextProcessEvents; |
63 | + CCSContextReadSettings contextReadSettings; |
64 | + CCSContextWriteSettings contextWriteSettings; |
65 | + CCSContextWriteChangedSettings contextWriteChangedSettings; |
66 | + CCSContextExportToFile contextExportToFile; |
67 | + CCSContextImportFromFile contextImportFromFile; |
68 | + CCSContextCanEnablePlugin contextCanEnablePlugin; |
69 | + CCSContextCanDisablePlugin contextCanDisablePlugin; |
70 | + CCSContextGetExistingProfiles contextGetExistingProfiles; |
71 | + CCSContextDeleteProfile contextDeleteProfile; |
72 | + CCSContextCheckForSettingsUpgrade contextCheckForSettingsUpgrade; |
73 | + CCSContextLoadPlugins contextLoadPlugins; |
74 | }; |
75 | |
76 | +inline unsigned int ccsCCSContextInterfaceGetType (); |
77 | + |
78 | /* CCSContext accessor functions */ |
79 | CCSPluginList ccsContextGetPlugins (CCSContext *); |
80 | CCSPluginCategory * ccsContextGetCategories (CCSContext *); |
81 | @@ -305,8 +359,7 @@ |
82 | |
83 | struct _CCSContext |
84 | { |
85 | - void *ccsPrivate; /* private pointer for compizconfig |
86 | - internal usage */ |
87 | + CCSObject object; |
88 | }; |
89 | |
90 | struct _CCSBackendInfo |
91 | @@ -1049,9 +1102,6 @@ |
92 | |
93 | CCSStrExtensionList ccsGetPluginStrExtensions (CCSPlugin *plugin); |
94 | |
95 | -/* Checks if settings need to be constrained */ |
96 | -Bool ccsContextNeedsConstraining (CCSContext *context); |
97 | - |
98 | #ifdef __cplusplus |
99 | } |
100 | #endif |
101 | |
102 | === modified file 'src/ccs-private.h' |
103 | --- src/ccs-private.h 2012-05-07 14:58:24 +0000 |
104 | +++ src/ccs-private.h 2012-05-07 14:58:24 +0000 |
105 | @@ -26,7 +26,7 @@ |
106 | #include <ccs-backend.h> |
107 | |
108 | #define CONTEXT_PRIV(c) \ |
109 | - CCSContextPrivate *cPrivate = (CCSContextPrivate *) c->ccsPrivate; |
110 | + CCSContextPrivate *cPrivate = (CCSContextPrivate *) ccsObjectGetPrivate (c); |
111 | #define PLUGIN_PRIV(p) \ |
112 | CCSPluginPrivate *pPrivate = (CCSPluginPrivate *) p->ccsPrivate; |
113 | |
114 | @@ -51,7 +51,6 @@ |
115 | |
116 | unsigned int screenNum; /* screen number this context is assigned to */ |
117 | const CCSInterfaceTable *object_interfaces; |
118 | - const CCSContextInterface *interface; |
119 | } CCSContextPrivate; |
120 | |
121 | typedef struct _CCSPluginPrivate |
122 | @@ -89,6 +88,9 @@ |
123 | void ccsLoadPluginSettings (CCSPlugin * plugin); |
124 | void collateGroups (CCSPluginPrivate * p); |
125 | |
126 | +Bool ccsLoadPluginDefault (CCSContext *context, char *name); |
127 | +void ccsLoadPluginsDefault (CCSContext *context); |
128 | + |
129 | void ccsCheckFileWatches (void); |
130 | |
131 | typedef enum { |
132 | |
133 | === modified file 'src/compiz.cpp' |
134 | --- src/compiz.cpp 2012-05-07 14:58:24 +0000 |
135 | +++ src/compiz.cpp 2012-05-07 14:58:24 +0000 |
136 | @@ -2991,7 +2991,7 @@ |
137 | #endif |
138 | |
139 | Bool |
140 | -ccsLoadPlugin (CCSContext * context, char *name) |
141 | +ccsLoadPluginDefault (CCSContext * context, char *name) |
142 | { |
143 | #ifdef USE_PROTOBUF |
144 | initPBLoading (); |
145 | @@ -3021,8 +3021,14 @@ |
146 | return (ccsFindPlugin (context, name) != NULL); |
147 | } |
148 | |
149 | +Bool |
150 | +ccsLoadPlugin (CCSContext *context, char *name) |
151 | +{ |
152 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextLoadPlugin) (context, name); |
153 | +} |
154 | + |
155 | void |
156 | -ccsLoadPlugins (CCSContext * context) |
157 | +ccsLoadPluginsDefault (CCSContext * context) |
158 | { |
159 | D (D_FULL, "Adding plugins\n"); |
160 | |
161 | @@ -3056,6 +3062,12 @@ |
162 | loadPluginsFromName (context, (char *)PLUGINDIR); |
163 | } |
164 | |
165 | +void |
166 | +ccsLoadPlugins (CCSContext *context) |
167 | +{ |
168 | + (*(GET_INTERFACE (CCSContextInterface, context))->contextLoadPlugins) (context); |
169 | +} |
170 | + |
171 | static void |
172 | loadOptionsStringExtensionsFromXML (CCSPlugin * plugin, |
173 | void * pluginPBv, |
174 | |
175 | === modified file 'src/main.c' |
176 | --- src/main.c 2012-05-07 14:58:24 +0000 |
177 | +++ src/main.c 2012-05-07 14:58:24 +0000 |
178 | @@ -228,6 +228,8 @@ |
179 | return start; |
180 | } |
181 | |
182 | +INTERFACE_TYPE (CCSContextInterface) |
183 | + |
184 | Bool basicMetadata = FALSE; |
185 | |
186 | void |
187 | @@ -289,22 +291,28 @@ |
188 | CCSContext *context; |
189 | |
190 | context = calloc (1, sizeof (CCSContext)); |
191 | + |
192 | + ccsObjectInit (context, &ccsDefaultObjectAllocator); |
193 | + |
194 | if (!context) |
195 | return NULL; |
196 | |
197 | - context->ccsPrivate = calloc (1, sizeof (CCSContextPrivate)); |
198 | - if (!context->ccsPrivate) |
199 | + CCSContextPrivate *ccsPrivate = calloc (1, sizeof (CCSContextPrivate)); |
200 | + if (!ccsPrivate) |
201 | { |
202 | free (context); |
203 | return NULL; |
204 | } |
205 | |
206 | + ccsObjectSetPrivate (context, (CCSPrivate *) ccsPrivate); |
207 | + |
208 | CONTEXT_PRIV (context); |
209 | |
210 | cPrivate->object_interfaces = object_interfaces; |
211 | - cPrivate->interface = object_interfaces->contextInterface; |
212 | cPrivate->screenNum = screenNum; |
213 | |
214 | + ccsObjectAddInterface (context, (CCSInterface *) object_interfaces->contextInterface, GET_INTERFACE_TYPE (CCSContextInterface)); |
215 | + |
216 | initGeneralOptions (context); |
217 | cPrivate->configWatchId = ccsAddConfigWatch (context, configChangeNotify); |
218 | |
219 | @@ -397,89 +405,58 @@ |
220 | return l; |
221 | } |
222 | |
223 | -static const CCSContextInterface ccsDefaultContextInterface = |
224 | -{ |
225 | - ccsContextGetPluginsDefault, |
226 | - ccsContextGetCategoriesDefault, |
227 | - ccsContextGetChangedSettingsDefault, |
228 | - ccsContextGetScreenNumDefault, |
229 | - ccsContextAddChangedSettingDefault, |
230 | - ccsContextClearChangedSettingsDefault, |
231 | - ccsContextStealChangedSettingsDefault, |
232 | - ccsContextGetPrivatePtrDefault, |
233 | - ccsContextSetPrivatePtrDefault |
234 | -}; |
235 | - |
236 | CCSPluginList |
237 | ccsContextGetPlugins (CCSContext *context) |
238 | { |
239 | - CONTEXT_PRIV (context); |
240 | - |
241 | - return (*cPrivate->interface->contextGetPlugins) (context); |
242 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextGetPlugins) (context); |
243 | } |
244 | |
245 | CCSPluginCategory * |
246 | ccsContextGetCategories (CCSContext *context) |
247 | { |
248 | - CONTEXT_PRIV (context); |
249 | - |
250 | - return (*cPrivate->interface->contextGetCategories) (context); |
251 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextGetCategories) (context); |
252 | } |
253 | |
254 | CCSSettingList |
255 | ccsContextGetChangedSettings (CCSContext *context) |
256 | { |
257 | - CONTEXT_PRIV (context); |
258 | - |
259 | - return (*cPrivate->interface->contextGetChangedSettings) (context); |
260 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextGetChangedSettings) (context); |
261 | } |
262 | |
263 | unsigned int |
264 | ccsContextGetScreenNum (CCSContext *context) |
265 | { |
266 | - CONTEXT_PRIV (context); |
267 | - |
268 | - return (*cPrivate->interface->contextGetScreenNum) (context); |
269 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextGetScreenNum) (context); |
270 | } |
271 | |
272 | Bool |
273 | ccsContextAddChangedSetting (CCSContext *context, CCSSetting *setting) |
274 | { |
275 | - CONTEXT_PRIV (context); |
276 | - |
277 | - return (*cPrivate->interface->contextAddChangedSetting) (context, setting); |
278 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextAddChangedSetting) (context, setting); |
279 | } |
280 | |
281 | Bool |
282 | ccsContextClearChangedSettings (CCSContext *context) |
283 | { |
284 | - CONTEXT_PRIV (context); |
285 | - |
286 | - return (*cPrivate->interface->contextClearChangedSettings) (context); |
287 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextClearChangedSettings) (context); |
288 | } |
289 | |
290 | CCSSettingList |
291 | ccsContextStealChangedSettings (CCSContext *context) |
292 | { |
293 | - CONTEXT_PRIV (context); |
294 | - |
295 | - return (*cPrivate->interface->contextStealChangedSettings) (context); |
296 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextStealChangedSettings) (context); |
297 | } |
298 | |
299 | void * |
300 | ccsContextGetPrivatePtr (CCSContext *context) |
301 | { |
302 | - CONTEXT_PRIV (context); |
303 | - |
304 | - return (*cPrivate->interface->contextGetPrivatePtr) (context); |
305 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextGetPrivatePtr) (context); |
306 | } |
307 | |
308 | void |
309 | ccsContextSetPrivatePtr (CCSContext *context, void *ptr) |
310 | { |
311 | - CONTEXT_PRIV (context); |
312 | - |
313 | - return (*cPrivate->interface->contextSetPrivatePtr) (context, ptr); |
314 | + (*(GET_INTERFACE (CCSContextInterface, context))->contextSetPrivatePtr) (context, ptr); |
315 | } |
316 | |
317 | void * |
318 | @@ -573,7 +550,7 @@ |
319 | } |
320 | |
321 | CCSPlugin * |
322 | -ccsFindPlugin (CCSContext * context, const char *name) |
323 | +ccsFindPluginDefault (CCSContext * context, const char *name) |
324 | { |
325 | if (!name) |
326 | name = ""; |
327 | @@ -592,6 +569,12 @@ |
328 | return NULL; |
329 | } |
330 | |
331 | +CCSPlugin * |
332 | +ccsFindPlugin (CCSContext *context, const char *name) |
333 | +{ |
334 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextFindPlugin) (context, name); |
335 | +} |
336 | + |
337 | CCSSetting * |
338 | ccsFindSetting (CCSPlugin * plugin, const char *name) |
339 | { |
340 | @@ -620,7 +603,7 @@ |
341 | } |
342 | |
343 | Bool |
344 | -ccsPluginIsActive (CCSContext * context, char *name) |
345 | +ccsPluginIsActiveDefault (CCSContext * context, char *name) |
346 | { |
347 | CCSPlugin *plugin; |
348 | |
349 | @@ -633,6 +616,12 @@ |
350 | return pPrivate->active; |
351 | } |
352 | |
353 | +Bool |
354 | +ccsPluginIsActive (CCSContext *context, char *name) |
355 | +{ |
356 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextPluginIsActive) (context, name); |
357 | +} |
358 | + |
359 | |
360 | static void |
361 | subGroupAdd (CCSSetting * setting, CCSGroup * group) |
362 | @@ -720,9 +709,7 @@ |
363 | |
364 | ccsPluginListFree (cPrivate->plugins, TRUE); |
365 | |
366 | - if (c->ccsPrivate) |
367 | - free (c->ccsPrivate); |
368 | - |
369 | + ccsObjectFinalize (c); |
370 | free (c); |
371 | } |
372 | |
373 | @@ -971,15 +958,14 @@ |
374 | CCSREF (StrExtension, CCSStrExtension) |
375 | |
376 | #define CCSREF_OBJ(type,dtype) \ |
377 | - void ccs##type##Ref (dtype *d) \ |
378 | + void ccs##type##Ref (dtype *d) \ |
379 | { \ |
380 | - ((CCSObject *) d)->refcnt++; \ |
381 | + ccsObjectRef (d); \ |
382 | } \ |
383 | + \ |
384 | void ccs##type##Unref (dtype *d) \ |
385 | { \ |
386 | - ((CCSObject *) d)->refcnt--; \ |
387 | - if (((CCSObject *) d)->refcnt == 0) \ |
388 | - ccsFree##type (d); \ |
389 | + ccsObjectUnref (d, ccsFree##type); \ |
390 | } \ |
391 | |
392 | static void * |
393 | @@ -1021,7 +1007,7 @@ |
394 | } |
395 | |
396 | Bool |
397 | -ccsSetBackend (CCSContext * context, char *name) |
398 | +ccsSetBackendDefault (CCSContext * context, char *name) |
399 | { |
400 | Bool fallbackMode = FALSE; |
401 | CONTEXT_PRIV (context); |
402 | @@ -1086,6 +1072,11 @@ |
403 | return TRUE; |
404 | } |
405 | |
406 | +Bool |
407 | +ccsSetBackend (CCSContext *context, char *name) |
408 | +{ |
409 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextSetBackend) (context, name); |
410 | +} |
411 | |
412 | static Bool |
413 | ccsCompareLists (CCSSettingValueList l1, CCSSettingValueList l2, |
414 | @@ -2044,7 +2035,7 @@ |
415 | } |
416 | |
417 | CCSPluginList |
418 | -ccsGetActivePluginList (CCSContext * context) |
419 | +ccsGetActivePluginListDefault (CCSContext * context) |
420 | { |
421 | CONTEXT_PRIV (context); |
422 | |
423 | @@ -2065,6 +2056,12 @@ |
424 | return rv; |
425 | } |
426 | |
427 | +CCSPluginList |
428 | +ccsGetActivePluginList (CCSContext *context) |
429 | +{ |
430 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextGetActivePluginList) (context); |
431 | +} |
432 | + |
433 | static CCSPlugin * |
434 | findPluginInList (CCSPluginList list, char *name) |
435 | { |
436 | @@ -2089,7 +2086,7 @@ |
437 | } PluginSortHelper; |
438 | |
439 | CCSStringList |
440 | -ccsGetSortedPluginStringList (CCSContext * context) |
441 | +ccsGetSortedPluginStringListDefault (CCSContext * context) |
442 | { |
443 | CCSPluginList ap = ccsGetActivePluginList (context); |
444 | CCSPluginList list; |
445 | @@ -2249,8 +2246,14 @@ |
446 | return rv; |
447 | } |
448 | |
449 | +CCSStringList |
450 | +ccsGetSortedPluginStringList (CCSContext *context) |
451 | +{ |
452 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextGetSortedPluginStringList) (context); |
453 | +} |
454 | + |
455 | char * |
456 | -ccsGetBackend (CCSContext * context) |
457 | +ccsGetBackendDefault (CCSContext * context) |
458 | { |
459 | if (!context) |
460 | return NULL; |
461 | @@ -2263,8 +2266,14 @@ |
462 | return cPrivate->backend->vTable->name; |
463 | } |
464 | |
465 | +char * |
466 | +ccsGetBackend (CCSContext *context) |
467 | +{ |
468 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextGetBackend) (context); |
469 | +} |
470 | + |
471 | Bool |
472 | -ccsGetIntegrationEnabled (CCSContext * context) |
473 | +ccsGetIntegrationEnabledDefault (CCSContext * context) |
474 | { |
475 | if (!context) |
476 | return FALSE; |
477 | @@ -2274,8 +2283,17 @@ |
478 | return cPrivate->deIntegration; |
479 | } |
480 | |
481 | +Bool |
482 | +ccsGetIntegrationEnabled (CCSContext *context) |
483 | +{ |
484 | + if (!context) |
485 | + return FALSE; |
486 | + |
487 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextGetIntegrationEnabled) (context); |
488 | +} |
489 | + |
490 | char * |
491 | -ccsGetProfile (CCSContext * context) |
492 | +ccsGetProfileDefault (CCSContext * context) |
493 | { |
494 | if (!context) |
495 | return NULL; |
496 | @@ -2285,8 +2303,17 @@ |
497 | return cPrivate->profile; |
498 | } |
499 | |
500 | +char * |
501 | +ccsGetProfile (CCSContext *context) |
502 | +{ |
503 | + if (!context) |
504 | + return NULL; |
505 | + |
506 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextGetProfile) (context); |
507 | +} |
508 | + |
509 | Bool |
510 | -ccsGetPluginListAutoSort (CCSContext * context) |
511 | +ccsGetPluginListAutoSortDefault (CCSContext * context) |
512 | { |
513 | if (!context) |
514 | return FALSE; |
515 | @@ -2296,8 +2323,17 @@ |
516 | return cPrivate->pluginListAutoSort; |
517 | } |
518 | |
519 | +Bool |
520 | +ccsGetPluginListAutoSort (CCSContext *context) |
521 | +{ |
522 | + if (!context) |
523 | + return FALSE; |
524 | + |
525 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextGetPluginListAutoSort) (context); |
526 | +} |
527 | + |
528 | void |
529 | -ccsSetIntegrationEnabled (CCSContext * context, Bool value) |
530 | +ccsSetIntegrationEnabledDefault (CCSContext * context, Bool value) |
531 | { |
532 | CONTEXT_PRIV (context); |
533 | |
534 | @@ -2313,6 +2349,12 @@ |
535 | ccsEnableFileWatch (cPrivate->configWatchId); |
536 | } |
537 | |
538 | +void |
539 | +ccsSetIntegrationEnabled (CCSContext *context, Bool value) |
540 | +{ |
541 | + (*(GET_INTERFACE (CCSContextInterface, context))->contextSetIntegrationEnabled) (context, value); |
542 | +} |
543 | + |
544 | static void |
545 | ccsWriteAutoSortedPluginList (CCSContext *context) |
546 | { |
547 | @@ -2340,7 +2382,7 @@ |
548 | } |
549 | |
550 | void |
551 | -ccsSetPluginListAutoSort (CCSContext * context, Bool value) |
552 | +ccsSetPluginListAutoSortDefault (CCSContext * context, Bool value) |
553 | { |
554 | CONTEXT_PRIV (context); |
555 | |
556 | @@ -2360,7 +2402,13 @@ |
557 | } |
558 | |
559 | void |
560 | -ccsSetProfile (CCSContext * context, char *name) |
561 | +ccsSetPluginListAutoSort (CCSContext *context, Bool value) |
562 | +{ |
563 | + (*(GET_INTERFACE (CCSContextInterface, context))->contextSetPluginListAutoSort) (context, value); |
564 | +} |
565 | + |
566 | +void |
567 | +ccsSetProfileDefault (CCSContext * context, char *name) |
568 | { |
569 | if (!name) |
570 | name = ""; |
571 | @@ -2382,7 +2430,13 @@ |
572 | } |
573 | |
574 | void |
575 | -ccsProcessEvents (CCSContext * context, unsigned int flags) |
576 | +ccsSetProfile (CCSContext *context, char *name) |
577 | +{ |
578 | + (*(GET_INTERFACE (CCSContextInterface, context))->contextSetProfile) (context, name); |
579 | +} |
580 | + |
581 | +void |
582 | +ccsProcessEventsDefault (CCSContext * context, unsigned int flags) |
583 | { |
584 | if (!context) |
585 | return; |
586 | @@ -2396,7 +2450,16 @@ |
587 | } |
588 | |
589 | void |
590 | -ccsReadSettings (CCSContext * context) |
591 | +ccsProcessEvents (CCSContext *context, unsigned int flags) |
592 | +{ |
593 | + if (!context) |
594 | + return; |
595 | + |
596 | + (*(GET_INTERFACE (CCSContextInterface, context))->contextProcessEvents) (context, flags); |
597 | +} |
598 | + |
599 | +void |
600 | +ccsReadSettingsDefault (CCSContext * context) |
601 | { |
602 | if (!context) |
603 | return; |
604 | @@ -2433,6 +2496,15 @@ |
605 | } |
606 | |
607 | void |
608 | +ccsReadSettings (CCSContext *context) |
609 | +{ |
610 | + if (!context) |
611 | + return; |
612 | + |
613 | + (*(GET_INTERFACE (CCSContextInterface, context))->contextReadSettings) (context); |
614 | +} |
615 | + |
616 | +void |
617 | ccsReadPluginSettings (CCSPlugin * plugin) |
618 | { |
619 | if (!plugin || !plugin->context) |
620 | @@ -2464,7 +2536,7 @@ |
621 | } |
622 | |
623 | void |
624 | -ccsWriteSettings (CCSContext * context) |
625 | +ccsWriteSettingsDefault (CCSContext * context) |
626 | { |
627 | if (!context) |
628 | return; |
629 | @@ -2504,7 +2576,16 @@ |
630 | } |
631 | |
632 | void |
633 | -ccsWriteChangedSettings (CCSContext * context) |
634 | +ccsWriteSettings (CCSContext *context) |
635 | +{ |
636 | + if (!context) |
637 | + return; |
638 | + |
639 | + (*(GET_INTERFACE (CCSContextInterface, context))->contextWriteSettings) (context); |
640 | +} |
641 | + |
642 | +void |
643 | +ccsWriteChangedSettingsDefault (CCSContext * context) |
644 | { |
645 | if (!context) |
646 | return; |
647 | @@ -2539,6 +2620,15 @@ |
648 | ccsSettingListFree (cPrivate->changedSettings, FALSE); |
649 | } |
650 | |
651 | +void |
652 | +ccsWriteChangedSettings (CCSContext *context) |
653 | +{ |
654 | + if (!context) |
655 | + return; |
656 | + |
657 | + (*(GET_INTERFACE (CCSContextInterface, context))->contextWriteChangedSettings) (context); |
658 | +} |
659 | + |
660 | Bool |
661 | ccsIsEqualColor (CCSSettingColorValue c1, CCSSettingColorValue c2) |
662 | { |
663 | @@ -2591,7 +2681,7 @@ |
664 | } |
665 | |
666 | CCSPluginConflictList |
667 | -ccsCanEnablePlugin (CCSContext * context, CCSPlugin * plugin) |
668 | +ccsCanEnablePluginDefault (CCSContext * context, CCSPlugin * plugin) |
669 | { |
670 | CCSPluginConflictList list = NULL; |
671 | CCSPluginList pl, pl2; |
672 | @@ -2809,7 +2899,13 @@ |
673 | } |
674 | |
675 | CCSPluginConflictList |
676 | -ccsCanDisablePlugin (CCSContext * context, CCSPlugin * plugin) |
677 | +ccsCanEnablePlugin (CCSContext *context, CCSPlugin *plugin) |
678 | +{ |
679 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextCanEnablePlugin) (context, plugin); |
680 | +} |
681 | + |
682 | +CCSPluginConflictList |
683 | +ccsCanDisablePluginDefault (CCSContext * context, CCSPlugin * plugin) |
684 | { |
685 | CCSPluginConflictList list = NULL; |
686 | CCSPluginConflict *conflict = NULL; |
687 | @@ -2912,8 +3008,14 @@ |
688 | return list; |
689 | } |
690 | |
691 | +CCSPluginConflictList |
692 | +ccsCanDisablePlugin (CCSContext *context, CCSPlugin *plugin) |
693 | +{ |
694 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextCanDisablePlugin) (context, plugin); |
695 | +} |
696 | + |
697 | CCSStringList |
698 | -ccsGetExistingProfiles (CCSContext * context) |
699 | +ccsGetExistingProfilesDefault (CCSContext * context) |
700 | { |
701 | if (!context) |
702 | return NULL; |
703 | @@ -2929,8 +3031,17 @@ |
704 | return NULL; |
705 | } |
706 | |
707 | +CCSStringList |
708 | +ccsGetExistingProfiles (CCSContext *context) |
709 | +{ |
710 | + if (!context) |
711 | + return NULL; |
712 | + |
713 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextGetExistingProfiles) (context); |
714 | +} |
715 | + |
716 | void |
717 | -ccsDeleteProfile (CCSContext * context, char *name) |
718 | +ccsDeleteProfileDefault (CCSContext * context, char *name) |
719 | { |
720 | if (!context) |
721 | return; |
722 | @@ -2953,6 +3064,15 @@ |
723 | (*cPrivate->backend->vTable->deleteProfile) (context, name); |
724 | } |
725 | |
726 | +void |
727 | +ccsDeleteProfile (CCSContext *context, char *name) |
728 | +{ |
729 | + if (!context) |
730 | + return; |
731 | + |
732 | + (*(GET_INTERFACE (CCSContextInterface, context))->contextDeleteProfile) (context, name); |
733 | +} |
734 | + |
735 | static void |
736 | addBackendInfo (CCSBackendInfoList * bl, char *file) |
737 | { |
738 | @@ -3081,9 +3201,9 @@ |
739 | } |
740 | |
741 | Bool |
742 | -ccsExportToFile (CCSContext *context, |
743 | - const char *fileName, |
744 | - Bool skipDefaults) |
745 | +ccsExportToFileDefault (CCSContext *context, |
746 | + const char *fileName, |
747 | + Bool skipDefaults) |
748 | { |
749 | IniDictionary *exportFile; |
750 | CCSPluginList p; |
751 | @@ -3176,6 +3296,15 @@ |
752 | return TRUE; |
753 | } |
754 | |
755 | +Bool |
756 | +ccsExportToFile (CCSContext *context, const char *fileName, Bool skipDefaults) |
757 | +{ |
758 | + if (!context) |
759 | + return FALSE; |
760 | + |
761 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextExportToFile) (context, fileName, skipDefaults); |
762 | +} |
763 | + |
764 | /* + with a value will attempt to append or overwrite that value if there is no - |
765 | * - with a value will attempt to clear any value set to that to the default |
766 | * if there is no + |
767 | @@ -3803,7 +3932,7 @@ |
768 | } |
769 | |
770 | Bool |
771 | -ccsCheckForSettingsUpgrade (CCSContext *context) |
772 | +ccsCheckForSettingsUpgradeDefault (CCSContext *context) |
773 | { |
774 | struct dirent **nameList; |
775 | int nFile, i; |
776 | @@ -3883,9 +4012,9 @@ |
777 | } |
778 | |
779 | Bool |
780 | -ccsImportFromFile (CCSContext *context, |
781 | - const char *fileName, |
782 | - Bool overwriteNonDefault) |
783 | +ccsImportFromFileDefault (CCSContext *context, |
784 | + const char *fileName, |
785 | + Bool overwriteNonDefault) |
786 | { |
787 | IniDictionary *importFile; |
788 | CCSPluginList p; |
789 | @@ -4047,6 +4176,21 @@ |
790 | return TRUE; |
791 | } |
792 | |
793 | +Bool |
794 | +ccsCheckForSettingsUpgrade (CCSContext *context) |
795 | +{ |
796 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextCheckForSettingsUpgrade) (context); |
797 | +} |
798 | + |
799 | +Bool |
800 | +ccsImportFromFile (CCSContext *context, const char *fileName, Bool overwriteNonDefault) |
801 | +{ |
802 | + if (!context) |
803 | + return FALSE; |
804 | + |
805 | + return (*(GET_INTERFACE (CCSContextInterface, context))->contextImportFromFile) (context, fileName, overwriteNonDefault); |
806 | +} |
807 | + |
808 | CCSSettingList ccsGetPluginSettings (CCSPlugin *plugin) |
809 | |
810 | { |
811 | @@ -4110,6 +4254,44 @@ |
812 | return pPrivate->stringExtensions; |
813 | } |
814 | |
815 | +static const CCSContextInterface ccsDefaultContextInterface = |
816 | +{ |
817 | + ccsContextGetPluginsDefault, |
818 | + ccsContextGetCategoriesDefault, |
819 | + ccsContextGetChangedSettingsDefault, |
820 | + ccsContextGetScreenNumDefault, |
821 | + ccsContextAddChangedSettingDefault, |
822 | + ccsContextClearChangedSettingsDefault, |
823 | + ccsContextStealChangedSettingsDefault, |
824 | + ccsContextGetPrivatePtrDefault, |
825 | + ccsContextSetPrivatePtrDefault, |
826 | + ccsLoadPluginDefault, |
827 | + ccsFindPluginDefault, |
828 | + ccsPluginIsActiveDefault, |
829 | + ccsGetActivePluginListDefault, |
830 | + ccsGetSortedPluginStringListDefault, |
831 | + ccsSetBackendDefault, |
832 | + ccsGetBackendDefault, |
833 | + ccsSetIntegrationEnabledDefault, |
834 | + ccsSetProfileDefault, |
835 | + ccsSetPluginListAutoSortDefault, |
836 | + ccsGetProfileDefault, |
837 | + ccsGetIntegrationEnabledDefault, |
838 | + ccsGetPluginListAutoSortDefault, |
839 | + ccsProcessEventsDefault, |
840 | + ccsReadSettingsDefault, |
841 | + ccsWriteSettingsDefault, |
842 | + ccsWriteChangedSettingsDefault, |
843 | + ccsExportToFileDefault, |
844 | + ccsImportFromFileDefault, |
845 | + ccsCanEnablePluginDefault, |
846 | + ccsCanDisablePluginDefault, |
847 | + ccsGetExistingProfilesDefault, |
848 | + ccsDeleteProfileDefault, |
849 | + ccsCheckForSettingsUpgradeDefault, |
850 | + ccsLoadPluginsDefault |
851 | +}; |
852 | + |
853 | const CCSInterfaceTable ccsDefaultInterfaceTable = |
854 | { |
855 | &ccsDefaultContextInterface |
GET_INTERFACE seems overcomplicated and error prone. It requires the first two parameters to match up - when in every use the second is a second macro with no other use that calls a third with the first parameter. Confused?
Current usage: GET_INTERFACE (CCSContextInte rface, CCS_CONTEXT_ INTERFACE_ TYPE, context)) rface, context))
Suggest usage: GET_INTERFACE (CCSContextInte
Current #define GET_INTERFACE( CType,IType, o) (CType *) ccsObjectGetInt erface ((CCSObject *) o, IType) CType, o) (CType* )ccsObjectGetIn terface( (CCSObject* ) o, GET_INTERFACE_ TYPE(CType) )
Suggest #define GET_INTERFACE(
And get rid of CCS_CONTEXT_ INTERFACE_ TYPE which is then unused.