summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--utils/themeeditor/main.c16
-rw-r--r--utils/themeeditor/main.cpp31
-rw-r--r--utils/themeeditor/skin_debug.h1
-rw-r--r--utils/themeeditor/skin_parser.c36
-rw-r--r--utils/themeeditor/skin_parser.h4
-rw-r--r--utils/themeeditor/skin_scan.h1
-rw-r--r--utils/themeeditor/tag_table.h8
-rw-r--r--utils/themeeditor/themeeditor.pro5
8 files changed, 76 insertions, 26 deletions
diff --git a/utils/themeeditor/main.c b/utils/themeeditor/main.c
deleted file mode 100644
index 269cad7840..0000000000
--- a/utils/themeeditor/main.c
+++ /dev/null
@@ -1,16 +0,0 @@
1#include "skin_parser.h"
2#include "skin_debug.h"
3
4#include <stdlib.h>
5#include <stdio.h>
6
7int main(int argc, char* argv[])
8{
9 char* doc = "%Vd(U))\n\n%?bl(test,3,5,2,1)<param2|param3>";
10
11 struct skin_element* test = skin_parse(doc);
12
13 skin_debug_tree(test);
14
15 return 0;
16}
diff --git a/utils/themeeditor/main.cpp b/utils/themeeditor/main.cpp
new file mode 100644
index 0000000000..3d7a01e7f2
--- /dev/null
+++ b/utils/themeeditor/main.cpp
@@ -0,0 +1,31 @@
1namespace wps
2{
3 extern "C"
4 {
5#include "skin_parser.h"
6#include "skin_debug.h"
7 }
8}
9
10#include <cstdlib>
11#include <cstdio>
12
13#include <QtGui/QApplication>
14#include <QFileSystemModel>
15#include <QTreeView>
16
17int main(int argc, char* argv[])
18{
19
20 char* doc = "%Vd(U)\n\n%?bl(test,3,5,2,1)<param2|param3>";
21
22 struct wps::skin_element* test = wps::skin_parse(doc);
23
24 wps::skin_debug_tree(test);
25
26 wps::skin_free_tree(test);
27
28
29 return 0;
30}
31
diff --git a/utils/themeeditor/skin_debug.h b/utils/themeeditor/skin_debug.h
index e5bac1ede1..c100eb1d2e 100644
--- a/utils/themeeditor/skin_debug.h
+++ b/utils/themeeditor/skin_debug.h
@@ -33,5 +33,4 @@ void skin_debug_tree(struct skin_element* root);
33void skin_debug_params(int count, struct skin_tag_parameter params[]); 33void skin_debug_params(int count, struct skin_tag_parameter params[]);
34void skin_debug_indent(); 34void skin_debug_indent();
35 35
36
37#endif // SKIN_DEBUG_H 36#endif // SKIN_DEBUG_H
diff --git a/utils/themeeditor/skin_parser.c b/utils/themeeditor/skin_parser.c
index bc1f2a5ed2..dd061a1ac9 100644
--- a/utils/themeeditor/skin_parser.c
+++ b/utils/themeeditor/skin_parser.c
@@ -32,7 +32,7 @@
32 32
33/* Declaration of parse tree buffer */ 33/* Declaration of parse tree buffer */
34char skin_parse_tree[SKIN_MAX_MEMORY]; 34char skin_parse_tree[SKIN_MAX_MEMORY];
35int skin_current_block = 0; 35int skin_current_block = 0;
36 36
37/* Global variables for the parser */ 37/* Global variables for the parser */
38int skin_line = 0; 38int skin_line = 0;
@@ -330,7 +330,6 @@ int skin_parse_tag(struct skin_element* element, char** document)
330 330
331 /* Copying basic tag info */ 331 /* Copying basic tag info */
332 element->type = TAG; 332 element->type = TAG;
333 element->name = skin_alloc_string(strlen(tag_name));
334 strcpy(element->name, tag_name); 333 strcpy(element->name, tag_name);
335 element->line = skin_line; 334 element->line = skin_line;
336 335
@@ -641,9 +640,6 @@ int skin_parse_newline(struct skin_element* element, char** document)
641 element->type = NEWLINE; 640 element->type = NEWLINE;
642 element->line = skin_line; 641 element->line = skin_line;
643 skin_line++; 642 skin_line++;
644 element->text = skin_alloc_string(1);
645 element->text[0] = '\n';
646 element->text[1] = '\0';
647 element->next = NULL; 643 element->next = NULL;
648 644
649 *document = cursor; 645 *document = cursor;
@@ -801,3 +797,33 @@ struct skin_element** skin_alloc_children(int count)
801{ 797{
802 return (struct skin_element**) malloc(sizeof(struct skin_element*) * count); 798 return (struct skin_element**) malloc(sizeof(struct skin_element*) * count);
803} 799}
800
801void skin_free_tree(struct skin_element* root)
802{
803 int i;
804
805 /* First make the recursive call */
806 if(!root)
807 return;
808 skin_free_tree(root->next);
809
810 /* Free any text */
811 if(root->type == TEXT)
812 free(root->text);
813
814 /* Then recursively free any children, before freeing their pointers */
815 for(i = 0; i < root->children_count; i++)
816 skin_free_tree(root->children[i]);
817 if(root->children_count > 0)
818 free(root->children);
819
820 /* Free any parameters, making sure to deallocate strings */
821 for(i = 0; i < root->params_count; i++)
822 if(root->params[i].type == STRING)
823 free(root->params[i].data.text);
824 if(root->params_count > 0)
825 free(root->params);
826
827 /* Finally, delete root's memory */
828 free(root);
829}
diff --git a/utils/themeeditor/skin_parser.h b/utils/themeeditor/skin_parser.h
index a6fd1aa206..50980023b5 100644
--- a/utils/themeeditor/skin_parser.h
+++ b/utils/themeeditor/skin_parser.h
@@ -93,7 +93,7 @@ struct skin_element
93 char* text; 93 char* text;
94 94
95 /* The tag or conditional name */ 95 /* The tag or conditional name */
96 char* name; 96 char name[3];
97 97
98 /* Pointer to and size of an array of parameters */ 98 /* Pointer to and size of an array of parameters */
99 int params_count; 99 int params_count;
@@ -121,4 +121,6 @@ struct skin_element** skin_alloc_children(int count);
121struct skin_tag_parameter* skin_alloc_params(int count); 121struct skin_tag_parameter* skin_alloc_params(int count);
122char* skin_alloc_string(int length); 122char* skin_alloc_string(int length);
123 123
124void skin_free_tree(struct skin_element* root);
125
124#endif /* GENERIC_PARSER_H */ 126#endif /* GENERIC_PARSER_H */
diff --git a/utils/themeeditor/skin_scan.h b/utils/themeeditor/skin_scan.h
index 863e9b7d64..210f39cdfd 100644
--- a/utils/themeeditor/skin_scan.h
+++ b/utils/themeeditor/skin_scan.h
@@ -28,5 +28,4 @@ void skip_whitespace(char** document);
28char* scan_string(char** document); 28char* scan_string(char** document);
29int scan_int(char** document); 29int scan_int(char** document);
30 30
31
32#endif // SCANNING_H 31#endif // SCANNING_H
diff --git a/utils/themeeditor/tag_table.h b/utils/themeeditor/tag_table.h
index 807d3e15ac..0fde717f11 100644
--- a/utils/themeeditor/tag_table.h
+++ b/utils/themeeditor/tag_table.h
@@ -22,6 +22,14 @@
22#ifndef TAG_TABLE_H 22#ifndef TAG_TABLE_H
23#define TAG_TABLE_H 23#define TAG_TABLE_H
24 24
25#ifdef __cplusplus
26extern "C"
27{
28namespace wps
29{
30#endif
31
32
25/* 33/*
26 * Struct for tag parsing information 34 * Struct for tag parsing information
27 * name - The name of the tag, i.e. V for %V 35 * name - The name of the tag, i.e. V for %V
diff --git a/utils/themeeditor/themeeditor.pro b/utils/themeeditor/themeeditor.pro
index 14b001db12..f3ce7f6810 100644
--- a/utils/themeeditor/themeeditor.pro
+++ b/utils/themeeditor/themeeditor.pro
@@ -1,10 +1,11 @@
1CONFIG += qt
1HEADERS += tag_table.h \ 2HEADERS += tag_table.h \
2 symbols.h \ 3 symbols.h \
3 skin_parser.h \ 4 skin_parser.h \
4 skin_scan.h \ 5 skin_scan.h \
5 skin_debug.h 6 skin_debug.h
6SOURCES += tag_table.c \ 7SOURCES += tag_table.c \
7 main.c \
8 skin_parser.c \ 8 skin_parser.c \
9 skin_scan.c \ 9 skin_scan.c \
10 skin_debug.c 10 skin_debug.c \
11 main.cpp