Merge lp:~liampwhite/inkscape/spfactory-gperf into lp:~inkscape.dev/inkscape/trunk
- spfactory-gperf
- Merge into trunk
Proposed by
Liam P. White
Status: | Needs review |
---|---|
Proposed branch: | lp:~liampwhite/inkscape/spfactory-gperf |
Merge into: | lp:~inkscape.dev/inkscape/trunk |
Diff against target: |
1080 lines (+826/-215) 2 files modified
src/sp-factory.cpp (+466/-215) src/sp-factory.gperf (+360/-0) |
To merge this branch: | bzr merge lp:~liampwhite/inkscape/spfactory-gperf |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Krzysztof Kosinski | Needs Fixing | ||
Review via email: mp+285286@code.launchpad.net |
Commit message
Description of the change
Converts SPFactory's strcmp chain to a constant-time hash table lookup.
Should improve loading performance by small amounts in complex documents.
To post a comment you must log in.
Revision history for this message
Liam P. White (liampwhite) wrote : | # |
1. No. strcmp is fast enough that most of the time you won't even notice the difference, especially for comparing small strings like these typenames.
2. That is the pain point of this merge proposal. IIRC win32 does not have gperf in its binaries. It might not be necessary but for pedanticism we would want to implement that (in both build systems, sigh.)
3. A trie has comparable or worse performance than a perfect hash table.
Revision history for this message
jazzynico (jazzynico) wrote : | # |
2. Gperf was added in the win32 devlibs rev. 55.But it's still missing in de win64 devlibs.
Unmerged revisions
- 14636. By Liam P. White
-
convert SPFactory to a gperf table
undo some earlier stupidity
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/sp-factory.cpp' |
2 | --- src/sp-factory.cpp 2015-08-23 07:08:26 +0000 |
3 | +++ src/sp-factory.cpp 2016-02-07 03:42:29 +0000 |
4 | @@ -1,16 +1,50 @@ |
5 | +/* ANSI-C code produced by gperf version 3.0.4 */ |
6 | +/* Command-line: gperf -CGD -t sp-factory.gperf */ |
7 | +/* Computed positions: -k'5,7,$' */ |
8 | + |
9 | +#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ |
10 | + && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \ |
11 | + && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \ |
12 | + && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \ |
13 | + && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \ |
14 | + && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \ |
15 | + && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \ |
16 | + && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \ |
17 | + && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \ |
18 | + && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \ |
19 | + && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \ |
20 | + && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \ |
21 | + && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \ |
22 | + && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \ |
23 | + && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \ |
24 | + && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \ |
25 | + && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \ |
26 | + && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \ |
27 | + && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \ |
28 | + && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \ |
29 | + && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \ |
30 | + && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ |
31 | + && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) |
32 | +/* The character set is not based on ISO-646. */ |
33 | +#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>." |
34 | +#endif |
35 | + |
36 | +#line 1 "sp-factory.gperf" |
37 | + |
38 | /* |
39 | * Factory for SPObject tree |
40 | * |
41 | * Authors: |
42 | * Markus Engel |
43 | + * Liam P. White |
44 | * |
45 | - * Copyright (C) 2013 Authors |
46 | + * Copyright (C) 2013-2016 Authors |
47 | * Released under GNU GPL, read the file 'COPYING' for more information |
48 | */ |
49 | |
50 | #include "sp-factory.h" |
51 | |
52 | -// primary |
53 | +// objects |
54 | #include "box3d.h" |
55 | #include "box3d-side.h" |
56 | #include "color-profile.h" |
57 | @@ -94,214 +128,28 @@ |
58 | #include "filters/tile.h" |
59 | #include "filters/turbulence.h" |
60 | |
61 | +#define NEW_OBJECT_FUNC(derived) \ |
62 | + static SPObject *create_##derived() { return new derived; } |
63 | + |
64 | +struct factory_object { |
65 | + char const *name; |
66 | + SPObject *(*create_func)(); |
67 | +}; |
68 | + |
69 | +factory_object const *get_object_create_func(char const *str, unsigned int len); |
70 | + |
71 | SPObject *SPFactory::createObject(std::string const& id) |
72 | { |
73 | SPObject *ret = NULL; |
74 | - |
75 | - if (id == "inkscape:box3d") |
76 | - ret = new SPBox3D; |
77 | - else if (id == "inkscape:box3dside") |
78 | - ret = new Box3DSide; |
79 | - else if (id == "svg:color-profile") |
80 | - ret = new Inkscape::ColorProfile; |
81 | - else if (id == "inkscape:persp3d") |
82 | - ret = new Persp3D; |
83 | - else if (id == "svg:a") |
84 | - ret = new SPAnchor; |
85 | - else if (id == "svg:clipPath") |
86 | - ret = new SPClipPath; |
87 | - else if (id == "svg:defs") |
88 | - ret = new SPDefs; |
89 | - else if (id == "svg:desc") |
90 | - ret = new SPDesc; |
91 | - else if (id == "svg:ellipse") { |
92 | - SPGenericEllipse *e = new SPGenericEllipse; |
93 | - e->type = SP_GENERIC_ELLIPSE_ELLIPSE; |
94 | - ret = e; |
95 | - } else if (id == "svg:circle") { |
96 | - SPGenericEllipse *c = new SPGenericEllipse; |
97 | - c->type = SP_GENERIC_ELLIPSE_CIRCLE; |
98 | - ret = c; |
99 | - } else if (id == "arc") { |
100 | - SPGenericEllipse *a = new SPGenericEllipse; |
101 | - a->type = SP_GENERIC_ELLIPSE_ARC; |
102 | - ret = a; |
103 | - } |
104 | - else if (id == "svg:filter") |
105 | - ret = new SPFilter; |
106 | - else if (id == "svg:flowDiv") |
107 | - ret = new SPFlowdiv; |
108 | - else if (id == "svg:flowSpan") |
109 | - ret = new SPFlowtspan; |
110 | - else if (id == "svg:flowPara") |
111 | - ret = new SPFlowpara; |
112 | - else if (id == "svg:flowLine") |
113 | - ret = new SPFlowline; |
114 | - else if (id == "svg:flowRegionBreak") |
115 | - ret = new SPFlowregionbreak; |
116 | - else if (id == "svg:flowRegion") |
117 | - ret = new SPFlowregion; |
118 | - else if (id == "svg:flowRegionExclude") |
119 | - ret = new SPFlowregionExclude; |
120 | - else if (id == "svg:flowRoot") |
121 | - ret = new SPFlowtext; |
122 | - else if (id == "svg:font") |
123 | - ret = new SPFont; |
124 | - else if (id == "svg:font-face") |
125 | - ret = new SPFontFace; |
126 | - else if (id == "svg:glyph") |
127 | - ret = new SPGlyph; |
128 | - else if (id == "svg:hkern") |
129 | - ret = new SPHkern; |
130 | - else if (id == "svg:vkern") |
131 | - ret = new SPVkern; |
132 | - else if (id == "sodipodi:guide") |
133 | - ret = new SPGuide; |
134 | - else if (id == "svg:hatch") |
135 | - ret = new SPHatch; |
136 | - else if (id == "svg:hatchPath") |
137 | - ret = new SPHatchPath; |
138 | - else if (id == "svg:image") |
139 | - ret = new SPImage; |
140 | - else if (id == "svg:g") |
141 | - ret = new SPGroup; |
142 | - else if (id == "svg:line") |
143 | - ret = new SPLine; |
144 | - else if (id == "svg:linearGradient") |
145 | - ret = new SPLinearGradient; |
146 | - else if (id == "svg:marker") |
147 | - ret = new SPMarker; |
148 | - else if (id == "svg:mask") |
149 | - ret = new SPMask; |
150 | - else if (id == "svg:mesh") |
151 | - ret = new SPMesh; |
152 | - else if (id == "svg:meshpatch") |
153 | - ret = new SPMeshpatch; |
154 | - else if (id == "svg:meshrow") |
155 | - ret = new SPMeshrow; |
156 | - else if (id == "svg:metadata") |
157 | - ret = new SPMetadata; |
158 | - else if (id == "svg:missing-glyph") |
159 | - ret = new SPMissingGlyph; |
160 | - else if (id == "sodipodi:namedview") |
161 | - ret = new SPNamedView; |
162 | - else if (id == "inkscape:offset") |
163 | - ret = new SPOffset; |
164 | - else if (id == "svg:path") |
165 | - ret = new SPPath; |
166 | - else if (id == "svg:pattern") |
167 | - ret = new SPPattern; |
168 | - else if (id == "svg:polygon") |
169 | - ret = new SPPolygon; |
170 | - else if (id == "svg:polyline") |
171 | - ret = new SPPolyLine; |
172 | - else if (id == "svg:radialGradient") |
173 | - ret = new SPRadialGradient; |
174 | - else if (id == "svg:rect") |
175 | - ret = new SPRect; |
176 | - else if (id == "svg:svg") |
177 | - ret = new SPRoot; |
178 | - else if (id == "svg:script") |
179 | - ret = new SPScript; |
180 | - else if (id == "svg:solidColor") |
181 | - ret = new SPSolidColor; |
182 | - else if (id == "spiral") |
183 | - ret = new SPSpiral; |
184 | - else if (id == "star") |
185 | - ret = new SPStar; |
186 | - else if (id == "svg:stop") |
187 | - ret = new SPStop; |
188 | - else if (id == "string") |
189 | - ret = new SPString; |
190 | - else if (id == "svg:style") |
191 | - ret = new SPStyleElem; |
192 | - else if (id == "svg:switch") |
193 | - ret = new SPSwitch; |
194 | - else if (id == "svg:symbol") |
195 | - ret = new SPSymbol; |
196 | - else if (id == "inkscape:tag") |
197 | - ret = new SPTag; |
198 | - else if (id == "inkscape:tagref") |
199 | - ret = new SPTagUse; |
200 | - else if (id == "svg:text") |
201 | - ret = new SPText; |
202 | - else if (id == "svg:title") |
203 | - ret = new SPTitle; |
204 | - else if (id == "svg:tref") |
205 | - ret = new SPTRef; |
206 | - else if (id == "svg:tspan") |
207 | - ret = new SPTSpan; |
208 | - else if (id == "svg:textPath") |
209 | - ret = new SPTextPath; |
210 | - else if (id == "svg:use") |
211 | - ret = new SPUse; |
212 | - else if (id == "inkscape:path-effect") |
213 | - ret = new LivePathEffectObject; |
214 | - |
215 | - |
216 | - // filters |
217 | - else if (id == "svg:feBlend") |
218 | - ret = new SPFeBlend; |
219 | - else if (id == "svg:feColorMatrix") |
220 | - ret = new SPFeColorMatrix; |
221 | - else if (id == "svg:feComponentTransfer") |
222 | - ret = new SPFeComponentTransfer; |
223 | - else if (id == "svg:feFuncR") |
224 | - ret = new SPFeFuncNode(SPFeFuncNode::R); |
225 | - else if (id == "svg:feFuncG") |
226 | - ret = new SPFeFuncNode(SPFeFuncNode::G); |
227 | - else if (id == "svg:feFuncB") |
228 | - ret = new SPFeFuncNode(SPFeFuncNode::B); |
229 | - else if (id == "svg:feFuncA") |
230 | - ret = new SPFeFuncNode(SPFeFuncNode::A); |
231 | - else if (id == "svg:feComposite") |
232 | - ret = new SPFeComposite; |
233 | - else if (id == "svg:feConvolveMatrix") |
234 | - ret = new SPFeConvolveMatrix; |
235 | - else if (id == "svg:feDiffuseLighting") |
236 | - ret = new SPFeDiffuseLighting; |
237 | - else if (id == "svg:feDisplacementMap") |
238 | - ret = new SPFeDisplacementMap; |
239 | - else if (id == "svg:feDistantLight") |
240 | - ret = new SPFeDistantLight; |
241 | - else if (id == "svg:feFlood") |
242 | - ret = new SPFeFlood; |
243 | - else if (id == "svg:feGaussianBlur") |
244 | - ret = new SPGaussianBlur; |
245 | - else if (id == "svg:feImage") |
246 | - ret = new SPFeImage; |
247 | - else if (id == "svg:feMerge") |
248 | - ret = new SPFeMerge; |
249 | - else if (id == "svg:feMergeNode") |
250 | - ret = new SPFeMergeNode; |
251 | - else if (id == "svg:feMorphology") |
252 | - ret = new SPFeMorphology; |
253 | - else if (id == "svg:feOffset") |
254 | - ret = new SPFeOffset; |
255 | - else if (id == "svg:fePointLight") |
256 | - ret = new SPFePointLight; |
257 | - else if (id == "svg:feSpecularLighting") |
258 | - ret = new SPFeSpecularLighting; |
259 | - else if (id == "svg:feSpotLight") |
260 | - ret = new SPFeSpotLight; |
261 | - else if (id == "svg:feTile") |
262 | - ret = new SPFeTile; |
263 | - else if (id == "svg:feTurbulence") |
264 | - ret = new SPFeTurbulence; |
265 | - else if (id == "inkscape:grid") |
266 | - ret = new SPObject; // TODO wtf |
267 | - else if (id == "rdf:RDF") // no SP node yet |
268 | - {} |
269 | - else if (id == "inkscape:clipboard") // SP node not necessary |
270 | - {} |
271 | - else if (id == "inkscape:_templateinfo") // ? |
272 | - {} |
273 | - else if (id.empty()) // comments |
274 | - {} |
275 | - else { |
276 | + if (id.empty()) return ret; |
277 | + |
278 | + factory_object const *obj = get_object_create_func(id.c_str(), id.length()); |
279 | + if (obj) { |
280 | + ret = obj->create_func(); |
281 | + } else { |
282 | fprintf(stderr, "WARNING: unknown type: %s\n", id.c_str()); |
283 | } |
284 | - |
285 | + |
286 | return ret; |
287 | } |
288 | |
289 | @@ -332,13 +180,416 @@ |
290 | return name; |
291 | } |
292 | |
293 | -/* |
294 | - Local Variables: |
295 | - mode:c++ |
296 | - c-file-style:"stroustrup" |
297 | - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) |
298 | - indent-tabs-mode:nil |
299 | - fill-column:99 |
300 | - End: |
301 | -*/ |
302 | -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : |
303 | +// objects |
304 | + |
305 | +NEW_OBJECT_FUNC(SPBox3D); |
306 | +NEW_OBJECT_FUNC(Box3DSide); |
307 | +NEW_OBJECT_FUNC(Persp3D); |
308 | +NEW_OBJECT_FUNC(SPAnchor); |
309 | +NEW_OBJECT_FUNC(SPClipPath); |
310 | +NEW_OBJECT_FUNC(SPDefs); |
311 | +NEW_OBJECT_FUNC(SPDesc); |
312 | +NEW_OBJECT_FUNC(SPFilter); |
313 | +NEW_OBJECT_FUNC(SPFlowdiv); |
314 | +NEW_OBJECT_FUNC(SPFlowtspan); |
315 | +NEW_OBJECT_FUNC(SPFlowpara); |
316 | +NEW_OBJECT_FUNC(SPFlowline); |
317 | +NEW_OBJECT_FUNC(SPFlowregionbreak); |
318 | +NEW_OBJECT_FUNC(SPFlowregion); |
319 | +NEW_OBJECT_FUNC(SPFlowregionExclude); |
320 | +NEW_OBJECT_FUNC(SPFlowtext); |
321 | +NEW_OBJECT_FUNC(SPFont); |
322 | +NEW_OBJECT_FUNC(SPFontFace); |
323 | +NEW_OBJECT_FUNC(SPGlyph); |
324 | +NEW_OBJECT_FUNC(SPHkern); |
325 | +NEW_OBJECT_FUNC(SPVkern); |
326 | +NEW_OBJECT_FUNC(SPGuide); |
327 | +NEW_OBJECT_FUNC(SPHatch); |
328 | +NEW_OBJECT_FUNC(SPHatchPath); |
329 | +NEW_OBJECT_FUNC(SPImage); |
330 | +NEW_OBJECT_FUNC(SPGroup); |
331 | +NEW_OBJECT_FUNC(SPLine); |
332 | +NEW_OBJECT_FUNC(SPLinearGradient); |
333 | +NEW_OBJECT_FUNC(SPMarker); |
334 | +NEW_OBJECT_FUNC(SPMask); |
335 | +NEW_OBJECT_FUNC(SPMesh); |
336 | +NEW_OBJECT_FUNC(SPMeshpatch); |
337 | +NEW_OBJECT_FUNC(SPMeshrow); |
338 | +NEW_OBJECT_FUNC(SPMetadata); |
339 | +NEW_OBJECT_FUNC(SPMissingGlyph); |
340 | +NEW_OBJECT_FUNC(SPNamedView); |
341 | +NEW_OBJECT_FUNC(SPOffset); |
342 | +NEW_OBJECT_FUNC(SPPath); |
343 | +NEW_OBJECT_FUNC(SPPattern); |
344 | +NEW_OBJECT_FUNC(SPPolygon); |
345 | +NEW_OBJECT_FUNC(SPPolyLine); |
346 | +NEW_OBJECT_FUNC(SPRadialGradient); |
347 | +NEW_OBJECT_FUNC(SPRect); |
348 | +NEW_OBJECT_FUNC(SPRoot); |
349 | +NEW_OBJECT_FUNC(SPScript); |
350 | +NEW_OBJECT_FUNC(SPSolidColor); |
351 | +NEW_OBJECT_FUNC(SPSpiral); |
352 | +NEW_OBJECT_FUNC(SPStar); |
353 | +NEW_OBJECT_FUNC(SPStop); |
354 | +NEW_OBJECT_FUNC(SPString); |
355 | +NEW_OBJECT_FUNC(SPStyleElem); |
356 | +NEW_OBJECT_FUNC(SPSwitch); |
357 | +NEW_OBJECT_FUNC(SPSymbol); |
358 | +NEW_OBJECT_FUNC(SPTag); |
359 | +NEW_OBJECT_FUNC(SPTagUse); |
360 | +NEW_OBJECT_FUNC(SPText); |
361 | +NEW_OBJECT_FUNC(SPTitle); |
362 | +NEW_OBJECT_FUNC(SPTRef); |
363 | +NEW_OBJECT_FUNC(SPTSpan); |
364 | +NEW_OBJECT_FUNC(SPTextPath); |
365 | +NEW_OBJECT_FUNC(SPUse); |
366 | +NEW_OBJECT_FUNC(LivePathEffectObject); |
367 | +NEW_OBJECT_FUNC(SPObject); |
368 | + |
369 | +static SPObject *create_nothing() { return NULL; } |
370 | +static SPObject *create_ColorProfile() { return new Inkscape::ColorProfile; } |
371 | +static SPObject *create_ellipse() { |
372 | + SPGenericEllipse *e = new SPGenericEllipse; |
373 | + e->type = SP_GENERIC_ELLIPSE_ELLIPSE; |
374 | + return e; |
375 | +} |
376 | +static SPObject *create_circle() { |
377 | + SPGenericEllipse *e = new SPGenericEllipse; |
378 | + e->type = SP_GENERIC_ELLIPSE_CIRCLE; |
379 | + return e; |
380 | +} |
381 | +static SPObject *create_arc() { |
382 | + SPGenericEllipse *e = new SPGenericEllipse; |
383 | + e->type = SP_GENERIC_ELLIPSE_ARC; |
384 | + return e; |
385 | +} |
386 | + |
387 | +// filters |
388 | + |
389 | +NEW_OBJECT_FUNC(SPFeBlend); |
390 | +NEW_OBJECT_FUNC(SPFeColorMatrix); |
391 | +NEW_OBJECT_FUNC(SPFeComponentTransfer); |
392 | +NEW_OBJECT_FUNC(SPFeComposite); |
393 | +NEW_OBJECT_FUNC(SPFeConvolveMatrix); |
394 | +NEW_OBJECT_FUNC(SPFeDiffuseLighting); |
395 | +NEW_OBJECT_FUNC(SPFeDisplacementMap); |
396 | +NEW_OBJECT_FUNC(SPFeDistantLight); |
397 | +NEW_OBJECT_FUNC(SPFeFlood); |
398 | +NEW_OBJECT_FUNC(SPGaussianBlur); |
399 | +NEW_OBJECT_FUNC(SPFeImage); |
400 | +NEW_OBJECT_FUNC(SPFeMerge); |
401 | +NEW_OBJECT_FUNC(SPFeMergeNode); |
402 | +NEW_OBJECT_FUNC(SPFeMorphology); |
403 | +NEW_OBJECT_FUNC(SPFeOffset); |
404 | +NEW_OBJECT_FUNC(SPFePointLight); |
405 | +NEW_OBJECT_FUNC(SPFeSpecularLighting); |
406 | +NEW_OBJECT_FUNC(SPFeSpotLight); |
407 | +NEW_OBJECT_FUNC(SPFeTile); |
408 | +NEW_OBJECT_FUNC(SPFeTurbulence); |
409 | + |
410 | +static SPObject *create_SPFeFuncNode_R() { return new SPFeFuncNode(SPFeFuncNode::R); } |
411 | +static SPObject *create_SPFeFuncNode_G() { return new SPFeFuncNode(SPFeFuncNode::G); } |
412 | +static SPObject *create_SPFeFuncNode_B() { return new SPFeFuncNode(SPFeFuncNode::B); } |
413 | +static SPObject *create_SPFeFuncNode_A() { return new SPFeFuncNode(SPFeFuncNode::A); } |
414 | +#line 265 "sp-factory.gperf" |
415 | +struct factory_object; |
416 | + |
417 | +#define TOTAL_KEYWORDS 94 |
418 | +#define MIN_WORD_LENGTH 3 |
419 | +#define MAX_WORD_LENGTH 23 |
420 | +#define MIN_HASH_VALUE 3 |
421 | +#define MAX_HASH_VALUE 151 |
422 | +/* maximum key range = 149, duplicates = 0 */ |
423 | + |
424 | +#ifdef __GNUC__ |
425 | +__inline |
426 | +#else |
427 | +#ifdef __cplusplus |
428 | +inline |
429 | +#endif |
430 | +#endif |
431 | +static unsigned int |
432 | +hash (register const char *str, register unsigned int len) |
433 | +{ |
434 | + static const unsigned char asso_values[] = |
435 | + { |
436 | + 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, |
437 | + 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, |
438 | + 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, |
439 | + 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, |
440 | + 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, |
441 | + 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, |
442 | + 152, 152, 152, 152, 152, 90, 60, 40, 35, 152, |
443 | + 0, 70, 152, 75, 152, 152, 152, 35, 152, 25, |
444 | + 70, 152, 5, 25, 55, 152, 152, 152, 152, 152, |
445 | + 152, 152, 152, 152, 152, 152, 152, 55, 152, 0, |
446 | + 45, 5, 35, 40, 60, 10, 152, 50, 15, 0, |
447 | + 10, 0, 10, 152, 20, 40, 0, 0, 20, 30, |
448 | + 5, 10, 152, 152, 152, 152, 152, 152, 152, 152, |
449 | + 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, |
450 | + 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, |
451 | + 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, |
452 | + 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, |
453 | + 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, |
454 | + 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, |
455 | + 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, |
456 | + 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, |
457 | + 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, |
458 | + 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, |
459 | + 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, |
460 | + 152, 152, 152, 152, 152, 152, 152, 152, 152, 152, |
461 | + 152, 152, 152, 152, 152, 152 |
462 | + }; |
463 | + register int hval = len; |
464 | + |
465 | + switch (hval) |
466 | + { |
467 | + default: |
468 | + hval += asso_values[(unsigned char)str[6]]; |
469 | + /*FALLTHROUGH*/ |
470 | + case 6: |
471 | + case 5: |
472 | + hval += asso_values[(unsigned char)str[4]]; |
473 | + /*FALLTHROUGH*/ |
474 | + case 4: |
475 | + case 3: |
476 | + break; |
477 | + } |
478 | + return hval + asso_values[(unsigned char)str[len - 1]]; |
479 | +} |
480 | + |
481 | +static const struct factory_object wordlist[] = |
482 | + { |
483 | +#line 277 "sp-factory.gperf" |
484 | + {"arc", create_arc}, |
485 | +#line 358 "sp-factory.gperf" |
486 | + {"rdf:RDF", create_nothing}, |
487 | +#line 326 "sp-factory.gperf" |
488 | + {"svg:text", create_SPText}, |
489 | +#line 327 "sp-factory.gperf" |
490 | + {"svg:title", create_SPTitle}, |
491 | +#line 331 "sp-factory.gperf" |
492 | + {"svg:use", create_SPUse}, |
493 | +#line 318 "sp-factory.gperf" |
494 | + {"star", create_SPStar}, |
495 | +#line 307 "sp-factory.gperf" |
496 | + {"inkscape:offset", create_SPOffset}, |
497 | +#line 313 "sp-factory.gperf" |
498 | + {"svg:rect", create_SPRect}, |
499 | +#line 329 "sp-factory.gperf" |
500 | + {"svg:tspan", create_SPTSpan}, |
501 | +#line 332 "sp-factory.gperf" |
502 | + {"inkscape:path-effect", create_LivePathEffectObject}, |
503 | +#line 309 "sp-factory.gperf" |
504 | + {"svg:pattern", create_SPPattern}, |
505 | +#line 360 "sp-factory.gperf" |
506 | + {"inkscape:_templateinfo", create_nothing}, |
507 | +#line 268 "sp-factory.gperf" |
508 | + {"inkscape:box3dside", create_Box3DSide}, |
509 | +#line 276 "sp-factory.gperf" |
510 | + {"svg:circle", create_circle}, |
511 | +#line 275 "sp-factory.gperf" |
512 | + {"svg:ellipse", create_ellipse}, |
513 | +#line 270 "sp-factory.gperf" |
514 | + {"svg:color-profile", create_ColorProfile}, |
515 | +#line 297 "sp-factory.gperf" |
516 | + {"svg:line", create_SPLine}, |
517 | +#line 311 "sp-factory.gperf" |
518 | + {"svg:polyline", create_SPPolyLine}, |
519 | +#line 298 "sp-factory.gperf" |
520 | + {"svg:linearGradient", create_SPLinearGradient}, |
521 | +#line 291 "sp-factory.gperf" |
522 | + {"svg:vkern", create_SPVkern}, |
523 | +#line 310 "sp-factory.gperf" |
524 | + {"svg:polygon", create_SPPolygon}, |
525 | +#line 286 "sp-factory.gperf" |
526 | + {"svg:flowRoot", create_SPFlowtext}, |
527 | +#line 328 "sp-factory.gperf" |
528 | + {"svg:tref", create_SPTRef}, |
529 | +#line 299 "sp-factory.gperf" |
530 | + {"svg:marker", create_SPMarker}, |
531 | +#line 336 "sp-factory.gperf" |
532 | + {"svg:feFuncR", create_SPFeFuncNode_R}, |
533 | +#line 282 "sp-factory.gperf" |
534 | + {"svg:flowLine", create_SPFlowline}, |
535 | +#line 287 "sp-factory.gperf" |
536 | + {"svg:font", create_SPFont}, |
537 | +#line 320 "sp-factory.gperf" |
538 | + {"string", create_SPString}, |
539 | +#line 280 "sp-factory.gperf" |
540 | + {"svg:flowSpan", create_SPFlowtspan}, |
541 | +#line 319 "sp-factory.gperf" |
542 | + {"svg:stop", create_SPStop}, |
543 | +#line 283 "sp-factory.gperf" |
544 | + {"svg:flowRegion", create_SPFlowregion}, |
545 | +#line 325 "sp-factory.gperf" |
546 | + {"inkscape:tagref", create_SPTagUse}, |
547 | +#line 285 "sp-factory.gperf" |
548 | + {"svg:flowRegionExclude", create_SPFlowregionExclude}, |
549 | +#line 324 "sp-factory.gperf" |
550 | + {"inkscape:tag", create_SPTag}, |
551 | +#line 288 "sp-factory.gperf" |
552 | + {"svg:font-face", create_SPFontFace}, |
553 | +#line 321 "sp-factory.gperf" |
554 | + {"svg:style", create_SPStyleElem}, |
555 | +#line 323 "sp-factory.gperf" |
556 | + {"svg:symbol", create_SPSymbol}, |
557 | +#line 279 "sp-factory.gperf" |
558 | + {"svg:flowDiv", create_SPFlowdiv}, |
559 | +#line 304 "sp-factory.gperf" |
560 | + {"svg:metadata", create_SPMetadata}, |
561 | +#line 357 "sp-factory.gperf" |
562 | + {"inkscape:grid", create_SPObject}, |
563 | +#line 267 "sp-factory.gperf" |
564 | + {"inkscape:box3d", create_SPBox3D}, |
565 | +#line 315 "sp-factory.gperf" |
566 | + {"svg:script", create_SPScript}, |
567 | +#line 269 "sp-factory.gperf" |
568 | + {"inkscape:persp3d", create_Persp3D}, |
569 | +#line 351 "sp-factory.gperf" |
570 | + {"svg:feOffset", create_SPFeOffset}, |
571 | +#line 359 "sp-factory.gperf" |
572 | + {"inkscape:clipboard", create_nothing}, |
573 | +#line 292 "sp-factory.gperf" |
574 | + {"sodipodi:guide", create_SPGuide}, |
575 | +#line 354 "sp-factory.gperf" |
576 | + {"svg:feSpotLight", create_SPFeSpotLight}, |
577 | +#line 317 "sp-factory.gperf" |
578 | + {"spiral", create_SPSpiral}, |
579 | +#line 330 "sp-factory.gperf" |
580 | + {"svg:textPath", create_SPTextPath}, |
581 | +#line 308 "sp-factory.gperf" |
582 | + {"svg:path", create_SPPath}, |
583 | +#line 295 "sp-factory.gperf" |
584 | + {"svg:image", create_SPImage}, |
585 | +#line 278 "sp-factory.gperf" |
586 | + {"svg:filter", create_SPFilter}, |
587 | +#line 303 "sp-factory.gperf" |
588 | + {"svg:meshrow", create_SPMeshrow}, |
589 | +#line 272 "sp-factory.gperf" |
590 | + {"svg:clipPath", create_SPClipPath}, |
591 | +#line 312 "sp-factory.gperf" |
592 | + {"svg:radialGradient", create_SPRadialGradient}, |
593 | +#line 290 "sp-factory.gperf" |
594 | + {"svg:hkern", create_SPHkern}, |
595 | +#line 296 "sp-factory.gperf" |
596 | + {"svg:g", create_SPGroup}, |
597 | +#line 348 "sp-factory.gperf" |
598 | + {"svg:feMerge", create_SPFeMerge}, |
599 | +#line 344 "sp-factory.gperf" |
600 | + {"svg:feDistantLight", create_SPFeDistantLight}, |
601 | +#line 316 "sp-factory.gperf" |
602 | + {"svg:solidColor", create_SPSolidColor}, |
603 | +#line 349 "sp-factory.gperf" |
604 | + {"svg:feMergeNode", create_SPFeMergeNode}, |
605 | +#line 345 "sp-factory.gperf" |
606 | + {"svg:feFlood", create_SPFeFlood}, |
607 | +#line 274 "sp-factory.gperf" |
608 | + {"svg:desc", create_SPDesc}, |
609 | +#line 340 "sp-factory.gperf" |
610 | + {"svg:feComposite", create_SPFeComposite}, |
611 | +#line 350 "sp-factory.gperf" |
612 | + {"svg:feMorphology", create_SPFeMorphology}, |
613 | +#line 334 "sp-factory.gperf" |
614 | + {"svg:feColorMatrix", create_SPFeColorMatrix}, |
615 | +#line 300 "sp-factory.gperf" |
616 | + {"svg:mask", create_SPMask}, |
617 | +#line 341 "sp-factory.gperf" |
618 | + {"svg:feConvolveMatrix", create_SPFeConvolveMatrix}, |
619 | +#line 343 "sp-factory.gperf" |
620 | + {"svg:feDisplacementMap", create_SPFeDisplacementMap}, |
621 | +#line 281 "sp-factory.gperf" |
622 | + {"svg:flowPara", create_SPFlowpara}, |
623 | +#line 306 "sp-factory.gperf" |
624 | + {"sodipodi:namedview", create_SPNamedView}, |
625 | +#line 284 "sp-factory.gperf" |
626 | + {"svg:flowRegionBreak", create_SPFlowregionbreak}, |
627 | +#line 355 "sp-factory.gperf" |
628 | + {"svg:feTile", create_SPFeTile}, |
629 | +#line 338 "sp-factory.gperf" |
630 | + {"svg:feFuncB", create_SPFeFuncNode_B}, |
631 | +#line 301 "sp-factory.gperf" |
632 | + {"svg:mesh", create_SPMesh}, |
633 | +#line 356 "sp-factory.gperf" |
634 | + {"svg:feTurbulence", create_SPFeTurbulence}, |
635 | +#line 302 "sp-factory.gperf" |
636 | + {"svg:meshpatch", create_SPMeshpatch}, |
637 | +#line 271 "sp-factory.gperf" |
638 | + {"svg:a", create_SPAnchor}, |
639 | +#line 337 "sp-factory.gperf" |
640 | + {"svg:feFuncG", create_SPFeFuncNode_G}, |
641 | +#line 305 "sp-factory.gperf" |
642 | + {"svg:missing-glyph", create_SPMissingGlyph}, |
643 | +#line 335 "sp-factory.gperf" |
644 | + {"svg:feComponentTransfer", create_SPFeComponentTransfer}, |
645 | +#line 289 "sp-factory.gperf" |
646 | + {"svg:glyph", create_SPGlyph}, |
647 | +#line 322 "sp-factory.gperf" |
648 | + {"svg:switch", create_SPSwitch}, |
649 | +#line 352 "sp-factory.gperf" |
650 | + {"svg:fePointLight", create_SPFePointLight}, |
651 | +#line 353 "sp-factory.gperf" |
652 | + {"svg:feSpecularLighting", create_SPFeSpecularLighting}, |
653 | +#line 347 "sp-factory.gperf" |
654 | + {"svg:feImage", create_SPFeImage}, |
655 | +#line 314 "sp-factory.gperf" |
656 | + {"svg:svg", create_SPRoot}, |
657 | +#line 273 "sp-factory.gperf" |
658 | + {"svg:defs", create_SPDefs}, |
659 | +#line 293 "sp-factory.gperf" |
660 | + {"svg:hatch", create_SPHatch}, |
661 | +#line 342 "sp-factory.gperf" |
662 | + {"svg:feDiffuseLighting", create_SPFeDiffuseLighting}, |
663 | +#line 294 "sp-factory.gperf" |
664 | + {"svg:hatchPath", create_SPHatchPath}, |
665 | +#line 339 "sp-factory.gperf" |
666 | + {"svg:feFuncA", create_SPFeFuncNode_A}, |
667 | +#line 346 "sp-factory.gperf" |
668 | + {"svg:feGaussianBlur", create_SPGaussianBlur}, |
669 | +#line 333 "sp-factory.gperf" |
670 | + {"svg:feBlend", create_SPFeBlend} |
671 | + }; |
672 | + |
673 | +static const signed char lookup[] = |
674 | + { |
675 | + -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, 1, 2, |
676 | + 3, -1, -1, 4, -1, -1, -1, -1, -1, -1, 5, 6, -1, -1, |
677 | + 7, 8, 9, 10, 11, 12, -1, 13, 14, 15, 16, -1, -1, -1, |
678 | + 17, 18, 19, -1, 20, 21, 22, -1, 23, 24, 25, 26, -1, -1, |
679 | + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, |
680 | + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, |
681 | + 55, 56, 57, -1, 58, 59, 60, 61, -1, 62, -1, 63, 64, 65, |
682 | + 66, -1, 67, 68, 69, 70, 71, 72, 73, -1, 74, -1, -1, 75, |
683 | + -1, 76, -1, 77, 78, 79, 80, 81, 82, 83, 84, -1, -1, -1, |
684 | + 85, 86, 87, 88, -1, 89, -1, 90, -1, -1, 91, -1, -1, -1, |
685 | + -1, -1, -1, 92, -1, -1, -1, -1, -1, -1, -1, 93 |
686 | + }; |
687 | + |
688 | +#ifdef __GNUC__ |
689 | +__inline |
690 | +#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__ |
691 | +__attribute__ ((__gnu_inline__)) |
692 | +#endif |
693 | +#endif |
694 | +const struct factory_object * |
695 | +get_object_create_func (register const char *str, register unsigned int len) |
696 | +{ |
697 | + if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) |
698 | + { |
699 | + register int key = hash (str, len); |
700 | + |
701 | + if (key <= MAX_HASH_VALUE && key >= 0) |
702 | + { |
703 | + register int index = lookup[key]; |
704 | + |
705 | + if (index >= 0) |
706 | + { |
707 | + register const char *s = wordlist[index].name; |
708 | + |
709 | + if (*str == *s && !strcmp (str + 1, s + 1)) |
710 | + return &wordlist[index]; |
711 | + } |
712 | + } |
713 | + } |
714 | + return 0; |
715 | +} |
716 | |
717 | === added file 'src/sp-factory.gperf' |
718 | --- src/sp-factory.gperf 1970-01-01 00:00:00 +0000 |
719 | +++ src/sp-factory.gperf 2016-02-07 03:42:29 +0000 |
720 | @@ -0,0 +1,360 @@ |
721 | +%{ |
722 | +/* |
723 | + * Factory for SPObject tree |
724 | + * |
725 | + * Authors: |
726 | + * Markus Engel |
727 | + * Liam P. White |
728 | + * |
729 | + * Copyright (C) 2013-2016 Authors |
730 | + * Released under GNU GPL, read the file 'COPYING' for more information |
731 | + */ |
732 | + |
733 | +#include "sp-factory.h" |
734 | + |
735 | +// objects |
736 | +#include "box3d.h" |
737 | +#include "box3d-side.h" |
738 | +#include "color-profile.h" |
739 | +#include "persp3d.h" |
740 | +#include "sp-anchor.h" |
741 | +#include "sp-clippath.h" |
742 | +#include "sp-defs.h" |
743 | +#include "sp-desc.h" |
744 | +#include "sp-ellipse.h" |
745 | +#include "sp-filter.h" |
746 | +#include "sp-flowdiv.h" |
747 | +#include "sp-flowregion.h" |
748 | +#include "sp-flowtext.h" |
749 | +#include "sp-font.h" |
750 | +#include "sp-font-face.h" |
751 | +#include "sp-glyph.h" |
752 | +#include "sp-glyph-kerning.h" |
753 | +#include "sp-guide.h" |
754 | +#include "sp-hatch.h" |
755 | +#include "sp-hatch-path.h" |
756 | +#include "sp-image.h" |
757 | +#include "sp-item-group.h" |
758 | +#include "sp-line.h" |
759 | +#include "sp-linear-gradient.h" |
760 | +#include "sp-marker.h" |
761 | +#include "sp-mask.h" |
762 | +#include "sp-mesh.h" |
763 | +#include "sp-mesh-patch.h" |
764 | +#include "sp-mesh-row.h" |
765 | +#include "sp-metadata.h" |
766 | +#include "sp-missing-glyph.h" |
767 | +#include "sp-namedview.h" |
768 | +#include "sp-object.h" |
769 | +#include "sp-offset.h" |
770 | +#include "sp-path.h" |
771 | +#include "sp-pattern.h" |
772 | +#include "sp-polygon.h" |
773 | +#include "sp-polyline.h" |
774 | +#include "sp-radial-gradient.h" |
775 | +#include "sp-rect.h" |
776 | +#include "sp-root.h" |
777 | +#include "sp-script.h" |
778 | +#include "sp-solid-color.h" |
779 | +#include "sp-spiral.h" |
780 | +#include "sp-star.h" |
781 | +#include "sp-stop.h" |
782 | +#include "sp-string.h" |
783 | +#include "sp-style-elem.h" |
784 | +#include "sp-switch.h" |
785 | +#include "sp-symbol.h" |
786 | +#include "sp-tag.h" |
787 | +#include "sp-tag-use.h" |
788 | +#include "sp-text.h" |
789 | +#include "sp-textpath.h" |
790 | +#include "sp-title.h" |
791 | +#include "sp-tref.h" |
792 | +#include "sp-tspan.h" |
793 | +#include "sp-use.h" |
794 | +#include "live_effects/lpeobject.h" |
795 | + |
796 | +// filters |
797 | +#include "filters/blend.h" |
798 | +#include "filters/colormatrix.h" |
799 | +#include "filters/componenttransfer.h" |
800 | +#include "filters/componenttransfer-funcnode.h" |
801 | +#include "filters/composite.h" |
802 | +#include "filters/convolvematrix.h" |
803 | +#include "filters/diffuselighting.h" |
804 | +#include "filters/displacementmap.h" |
805 | +#include "filters/distantlight.h" |
806 | +#include "filters/flood.h" |
807 | +#include "filters/gaussian-blur.h" |
808 | +#include "filters/image.h" |
809 | +#include "filters/merge.h" |
810 | +#include "filters/mergenode.h" |
811 | +#include "filters/morphology.h" |
812 | +#include "filters/offset.h" |
813 | +#include "filters/pointlight.h" |
814 | +#include "filters/specularlighting.h" |
815 | +#include "filters/spotlight.h" |
816 | +#include "filters/tile.h" |
817 | +#include "filters/turbulence.h" |
818 | + |
819 | +#define NEW_OBJECT_FUNC(derived) \ |
820 | + static SPObject *create_##derived() { return new derived; } |
821 | + |
822 | +struct factory_object { |
823 | + char const *name; |
824 | + SPObject *(*create_func)(); |
825 | +}; |
826 | + |
827 | +factory_object const *get_object_create_func(char const *str, unsigned int len); |
828 | + |
829 | +SPObject *SPFactory::createObject(std::string const& id) |
830 | +{ |
831 | + SPObject *ret = NULL; |
832 | + if (id.empty()) return ret; |
833 | + |
834 | + factory_object const *obj = get_object_create_func(id.c_str(), id.length()); |
835 | + if (obj) { |
836 | + ret = obj->create_func(); |
837 | + } else { |
838 | + fprintf(stderr, "WARNING: unknown type: %s\n", id.c_str()); |
839 | + } |
840 | + |
841 | + return ret; |
842 | +} |
843 | + |
844 | +std::string NodeTraits::get_type_string(Inkscape::XML::Node const &node) |
845 | +{ |
846 | + std::string name; |
847 | + |
848 | + switch (node.type()) { |
849 | + case Inkscape::XML::TEXT_NODE: |
850 | + name = "string"; |
851 | + break; |
852 | + |
853 | + case Inkscape::XML::ELEMENT_NODE: { |
854 | + char const *const sptype = node.attribute("sodipodi:type"); |
855 | + |
856 | + if (sptype) { |
857 | + name = sptype; |
858 | + } else { |
859 | + name = node.name(); |
860 | + } |
861 | + break; |
862 | + } |
863 | + default: |
864 | + name = ""; |
865 | + break; |
866 | + } |
867 | + |
868 | + return name; |
869 | +} |
870 | + |
871 | +// objects |
872 | + |
873 | +NEW_OBJECT_FUNC(SPBox3D); |
874 | +NEW_OBJECT_FUNC(Box3DSide); |
875 | +NEW_OBJECT_FUNC(Persp3D); |
876 | +NEW_OBJECT_FUNC(SPAnchor); |
877 | +NEW_OBJECT_FUNC(SPClipPath); |
878 | +NEW_OBJECT_FUNC(SPDefs); |
879 | +NEW_OBJECT_FUNC(SPDesc); |
880 | +NEW_OBJECT_FUNC(SPFilter); |
881 | +NEW_OBJECT_FUNC(SPFlowdiv); |
882 | +NEW_OBJECT_FUNC(SPFlowtspan); |
883 | +NEW_OBJECT_FUNC(SPFlowpara); |
884 | +NEW_OBJECT_FUNC(SPFlowline); |
885 | +NEW_OBJECT_FUNC(SPFlowregionbreak); |
886 | +NEW_OBJECT_FUNC(SPFlowregion); |
887 | +NEW_OBJECT_FUNC(SPFlowregionExclude); |
888 | +NEW_OBJECT_FUNC(SPFlowtext); |
889 | +NEW_OBJECT_FUNC(SPFont); |
890 | +NEW_OBJECT_FUNC(SPFontFace); |
891 | +NEW_OBJECT_FUNC(SPGlyph); |
892 | +NEW_OBJECT_FUNC(SPHkern); |
893 | +NEW_OBJECT_FUNC(SPVkern); |
894 | +NEW_OBJECT_FUNC(SPGuide); |
895 | +NEW_OBJECT_FUNC(SPHatch); |
896 | +NEW_OBJECT_FUNC(SPHatchPath); |
897 | +NEW_OBJECT_FUNC(SPImage); |
898 | +NEW_OBJECT_FUNC(SPGroup); |
899 | +NEW_OBJECT_FUNC(SPLine); |
900 | +NEW_OBJECT_FUNC(SPLinearGradient); |
901 | +NEW_OBJECT_FUNC(SPMarker); |
902 | +NEW_OBJECT_FUNC(SPMask); |
903 | +NEW_OBJECT_FUNC(SPMesh); |
904 | +NEW_OBJECT_FUNC(SPMeshpatch); |
905 | +NEW_OBJECT_FUNC(SPMeshrow); |
906 | +NEW_OBJECT_FUNC(SPMetadata); |
907 | +NEW_OBJECT_FUNC(SPMissingGlyph); |
908 | +NEW_OBJECT_FUNC(SPNamedView); |
909 | +NEW_OBJECT_FUNC(SPOffset); |
910 | +NEW_OBJECT_FUNC(SPPath); |
911 | +NEW_OBJECT_FUNC(SPPattern); |
912 | +NEW_OBJECT_FUNC(SPPolygon); |
913 | +NEW_OBJECT_FUNC(SPPolyLine); |
914 | +NEW_OBJECT_FUNC(SPRadialGradient); |
915 | +NEW_OBJECT_FUNC(SPRect); |
916 | +NEW_OBJECT_FUNC(SPRoot); |
917 | +NEW_OBJECT_FUNC(SPScript); |
918 | +NEW_OBJECT_FUNC(SPSolidColor); |
919 | +NEW_OBJECT_FUNC(SPSpiral); |
920 | +NEW_OBJECT_FUNC(SPStar); |
921 | +NEW_OBJECT_FUNC(SPStop); |
922 | +NEW_OBJECT_FUNC(SPString); |
923 | +NEW_OBJECT_FUNC(SPStyleElem); |
924 | +NEW_OBJECT_FUNC(SPSwitch); |
925 | +NEW_OBJECT_FUNC(SPSymbol); |
926 | +NEW_OBJECT_FUNC(SPTag); |
927 | +NEW_OBJECT_FUNC(SPTagUse); |
928 | +NEW_OBJECT_FUNC(SPText); |
929 | +NEW_OBJECT_FUNC(SPTitle); |
930 | +NEW_OBJECT_FUNC(SPTRef); |
931 | +NEW_OBJECT_FUNC(SPTSpan); |
932 | +NEW_OBJECT_FUNC(SPTextPath); |
933 | +NEW_OBJECT_FUNC(SPUse); |
934 | +NEW_OBJECT_FUNC(LivePathEffectObject); |
935 | +NEW_OBJECT_FUNC(SPObject); |
936 | + |
937 | +static SPObject *create_nothing() { return NULL; } |
938 | +static SPObject *create_ColorProfile() { return new Inkscape::ColorProfile; } |
939 | +static SPObject *create_ellipse() { |
940 | + SPGenericEllipse *e = new SPGenericEllipse; |
941 | + e->type = SP_GENERIC_ELLIPSE_ELLIPSE; |
942 | + return e; |
943 | +} |
944 | +static SPObject *create_circle() { |
945 | + SPGenericEllipse *e = new SPGenericEllipse; |
946 | + e->type = SP_GENERIC_ELLIPSE_CIRCLE; |
947 | + return e; |
948 | +} |
949 | +static SPObject *create_arc() { |
950 | + SPGenericEllipse *e = new SPGenericEllipse; |
951 | + e->type = SP_GENERIC_ELLIPSE_ARC; |
952 | + return e; |
953 | +} |
954 | + |
955 | +// filters |
956 | + |
957 | +NEW_OBJECT_FUNC(SPFeBlend); |
958 | +NEW_OBJECT_FUNC(SPFeColorMatrix); |
959 | +NEW_OBJECT_FUNC(SPFeComponentTransfer); |
960 | +NEW_OBJECT_FUNC(SPFeComposite); |
961 | +NEW_OBJECT_FUNC(SPFeConvolveMatrix); |
962 | +NEW_OBJECT_FUNC(SPFeDiffuseLighting); |
963 | +NEW_OBJECT_FUNC(SPFeDisplacementMap); |
964 | +NEW_OBJECT_FUNC(SPFeDistantLight); |
965 | +NEW_OBJECT_FUNC(SPFeFlood); |
966 | +NEW_OBJECT_FUNC(SPGaussianBlur); |
967 | +NEW_OBJECT_FUNC(SPFeImage); |
968 | +NEW_OBJECT_FUNC(SPFeMerge); |
969 | +NEW_OBJECT_FUNC(SPFeMergeNode); |
970 | +NEW_OBJECT_FUNC(SPFeMorphology); |
971 | +NEW_OBJECT_FUNC(SPFeOffset); |
972 | +NEW_OBJECT_FUNC(SPFePointLight); |
973 | +NEW_OBJECT_FUNC(SPFeSpecularLighting); |
974 | +NEW_OBJECT_FUNC(SPFeSpotLight); |
975 | +NEW_OBJECT_FUNC(SPFeTile); |
976 | +NEW_OBJECT_FUNC(SPFeTurbulence); |
977 | + |
978 | +static SPObject *create_SPFeFuncNode_R() { return new SPFeFuncNode(SPFeFuncNode::R); } |
979 | +static SPObject *create_SPFeFuncNode_G() { return new SPFeFuncNode(SPFeFuncNode::G); } |
980 | +static SPObject *create_SPFeFuncNode_B() { return new SPFeFuncNode(SPFeFuncNode::B); } |
981 | +static SPObject *create_SPFeFuncNode_A() { return new SPFeFuncNode(SPFeFuncNode::A); } |
982 | +%} |
983 | +%language=ANSI-C |
984 | +%define lookup-function-name get_object_create_func |
985 | +struct factory_object |
986 | +%% |
987 | +inkscape:box3d, create_SPBox3D |
988 | +inkscape:box3dside, create_Box3DSide |
989 | +inkscape:persp3d, create_Persp3D |
990 | +svg:color-profile, create_ColorProfile |
991 | +svg:a, create_SPAnchor |
992 | +svg:clipPath, create_SPClipPath |
993 | +svg:defs, create_SPDefs |
994 | +svg:desc, create_SPDesc |
995 | +svg:ellipse, create_ellipse |
996 | +svg:circle, create_circle |
997 | +arc, create_arc |
998 | +svg:filter, create_SPFilter |
999 | +svg:flowDiv, create_SPFlowdiv |
1000 | +svg:flowSpan, create_SPFlowtspan |
1001 | +svg:flowPara, create_SPFlowpara |
1002 | +svg:flowLine, create_SPFlowline |
1003 | +svg:flowRegion, create_SPFlowregion |
1004 | +svg:flowRegionBreak, create_SPFlowregionbreak |
1005 | +svg:flowRegionExclude, create_SPFlowregionExclude |
1006 | +svg:flowRoot, create_SPFlowtext |
1007 | +svg:font, create_SPFont |
1008 | +svg:font-face, create_SPFontFace |
1009 | +svg:glyph, create_SPGlyph |
1010 | +svg:hkern, create_SPHkern |
1011 | +svg:vkern, create_SPVkern |
1012 | +sodipodi:guide, create_SPGuide |
1013 | +svg:hatch, create_SPHatch |
1014 | +svg:hatchPath, create_SPHatchPath |
1015 | +svg:image, create_SPImage |
1016 | +svg:g, create_SPGroup |
1017 | +svg:line, create_SPLine |
1018 | +svg:linearGradient, create_SPLinearGradient |
1019 | +svg:marker, create_SPMarker |
1020 | +svg:mask, create_SPMask |
1021 | +svg:mesh, create_SPMesh |
1022 | +svg:meshpatch, create_SPMeshpatch |
1023 | +svg:meshrow, create_SPMeshrow |
1024 | +svg:metadata, create_SPMetadata |
1025 | +svg:missing-glyph, create_SPMissingGlyph |
1026 | +sodipodi:namedview, create_SPNamedView |
1027 | +inkscape:offset, create_SPOffset |
1028 | +svg:path, create_SPPath |
1029 | +svg:pattern, create_SPPattern |
1030 | +svg:polygon, create_SPPolygon |
1031 | +svg:polyline, create_SPPolyLine |
1032 | +svg:radialGradient, create_SPRadialGradient |
1033 | +svg:rect, create_SPRect |
1034 | +svg:svg, create_SPRoot |
1035 | +svg:script, create_SPScript |
1036 | +svg:solidColor, create_SPSolidColor |
1037 | +spiral, create_SPSpiral |
1038 | +star, create_SPStar |
1039 | +svg:stop, create_SPStop |
1040 | +string, create_SPString |
1041 | +svg:style, create_SPStyleElem |
1042 | +svg:switch, create_SPSwitch |
1043 | +svg:symbol, create_SPSymbol |
1044 | +inkscape:tag, create_SPTag |
1045 | +inkscape:tagref, create_SPTagUse |
1046 | +svg:text, create_SPText |
1047 | +svg:title, create_SPTitle |
1048 | +svg:tref, create_SPTRef |
1049 | +svg:tspan, create_SPTSpan |
1050 | +svg:textPath, create_SPTextPath |
1051 | +svg:use, create_SPUse |
1052 | +inkscape:path-effect, create_LivePathEffectObject |
1053 | +svg:feBlend, create_SPFeBlend |
1054 | +svg:feColorMatrix, create_SPFeColorMatrix |
1055 | +svg:feComponentTransfer, create_SPFeComponentTransfer |
1056 | +svg:feFuncR, create_SPFeFuncNode_R |
1057 | +svg:feFuncG, create_SPFeFuncNode_G |
1058 | +svg:feFuncB, create_SPFeFuncNode_B |
1059 | +svg:feFuncA, create_SPFeFuncNode_A |
1060 | +svg:feComposite, create_SPFeComposite |
1061 | +svg:feConvolveMatrix, create_SPFeConvolveMatrix |
1062 | +svg:feDiffuseLighting, create_SPFeDiffuseLighting |
1063 | +svg:feDisplacementMap, create_SPFeDisplacementMap |
1064 | +svg:feDistantLight, create_SPFeDistantLight |
1065 | +svg:feFlood, create_SPFeFlood |
1066 | +svg:feGaussianBlur, create_SPGaussianBlur |
1067 | +svg:feImage, create_SPFeImage |
1068 | +svg:feMerge, create_SPFeMerge |
1069 | +svg:feMergeNode, create_SPFeMergeNode |
1070 | +svg:feMorphology, create_SPFeMorphology |
1071 | +svg:feOffset, create_SPFeOffset |
1072 | +svg:fePointLight, create_SPFePointLight |
1073 | +svg:feSpecularLighting, create_SPFeSpecularLighting |
1074 | +svg:feSpotLight, create_SPFeSpotLight |
1075 | +svg:feTile, create_SPFeTile |
1076 | +svg:feTurbulence, create_SPFeTurbulence |
1077 | +inkscape:grid, create_SPObject |
1078 | +rdf:RDF, create_nothing |
1079 | +inkscape:clipboard, create_nothing |
1080 | +inkscape:_templateinfo, create_nothing |
I am skeptical about this.
1. Do we have any evidence that the strcmp chain is a performance problem?
2. At a minimum, this must be integrated with the build system, so that sp-factory.cpp is automatically rebuilt whenever sp-factory.gperf is modified.
3. I'd rather see something based on a trie initialized at runtime, since it would be more generally useful; for instance, we could reuse it for ID lookup.