summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2015-09-23 17:17:50 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2015-09-23 17:17:50 +0100
commitc0d82ba900fb57dee2db74ba867aa47b7ecf26dc (patch)
tree64175e6d4227e7ca36b40d1e83c864f12546083e /src
parent411089d5e3082ce22f0bb2ee133b42bddf1d2b0a (diff)
eolian: preliminary doc dependency detection for external files
This doesn't quite work yet as path sanitization needs to be done for it to work correctly. For now this code path is disabled and will be enabled once all paths are correctly sanitized.
Diffstat (limited to 'src')
-rw-r--r--src/lib/eolian/database_fill.c17
-rw-r--r--src/lib/eolian/eo_lexer.c67
-rw-r--r--src/lib/eolian/eolian_database.c4
-rw-r--r--src/lib/eolian/eolian_database.h3
4 files changed, 91 insertions, 0 deletions
diff --git a/src/lib/eolian/database_fill.c b/src/lib/eolian/database_fill.c
index 2d43b6cf7d..037199113a 100644
--- a/src/lib/eolian/database_fill.c
+++ b/src/lib/eolian/database_fill.c
@@ -217,6 +217,7 @@ eo_parser_database_fill(const char *filename, Eina_Bool eot)
217 Eina_Iterator *itr; 217 Eina_Iterator *itr;
218 Eolian_Class *cl; 218 Eolian_Class *cl;
219 Eo_Lexer *ls; 219 Eo_Lexer *ls;
220 const char *dep;
220 221
221 if (eina_hash_find(_parsedeos, filename)) 222 if (eina_hash_find(_parsedeos, filename))
222 return EINA_TRUE; 223 return EINA_TRUE;
@@ -257,6 +258,7 @@ eo_parser_database_fill(const char *filename, Eina_Bool eot)
257 { 258 {
258 fprintf(stderr, "eolian: unable to find function '%s'\n", 259 fprintf(stderr, "eolian: unable to find function '%s'\n",
259 eolian_implement_full_name_get(impl)); 260 eolian_implement_full_name_get(impl));
261 eina_iterator_free(itr);
260 goto error; 262 goto error;
261 } 263 }
262 else if (eolian_function_is_constructor(impl->foo_id, impl->klass)) 264 else if (eolian_function_is_constructor(impl->foo_id, impl->klass))
@@ -271,6 +273,7 @@ eo_parser_database_fill(const char *filename, Eina_Bool eot)
271 { 273 {
272 fprintf(stderr, "eolian: unable to find function '%s'\n", 274 fprintf(stderr, "eolian: unable to find function '%s'\n",
273 eolian_constructor_full_name_get(ctor)); 275 eolian_constructor_full_name_get(ctor));
276 eina_iterator_free(itr);
274 goto error; 277 goto error;
275 } 278 }
276 else 279 else
@@ -278,6 +281,20 @@ eo_parser_database_fill(const char *filename, Eina_Bool eot)
278 } 281 }
279 eina_iterator_free(itr); 282 eina_iterator_free(itr);
280 283
284 /* parse deferred eos (doc dependencies) */
285 itr = eina_hash_iterator_data_new(_defereos);
286 EINA_ITERATOR_FOREACH(itr, dep)
287 {
288 if (!eina_hash_find(_parsingeos, dep) && !eolian_file_parse(dep))
289 {
290 eina_iterator_free(itr);
291 eina_hash_free_buckets(_defereos);
292 goto error;
293 }
294 }
295 eina_iterator_free(itr);
296 eina_hash_free_buckets(_defereos);
297
281done: 298done:
282 eina_hash_set(_parsedeos, filename, (void *)EINA_TRUE); 299 eina_hash_set(_parsedeos, filename, (void *)EINA_TRUE);
283 eina_hash_set(_parsingeos, filename, (void *)EINA_FALSE); 300 eina_hash_set(_parsingeos, filename, (void *)EINA_FALSE);
diff --git a/src/lib/eolian/eo_lexer.c b/src/lib/eolian/eo_lexer.c
index 456f0b1ab9..ced0890d42 100644
--- a/src/lib/eolian/eo_lexer.c
+++ b/src/lib/eolian/eo_lexer.c
@@ -253,6 +253,72 @@ enum Doc_Tokens {
253 DOC_MANGLED = -2, DOC_UNFINISHED = -1, DOC_TEXT = 0, DOC_SINCE = 1 253 DOC_MANGLED = -2, DOC_UNFINISHED = -1, DOC_TEXT = 0, DOC_SINCE = 1
254}; 254};
255 255
256static void
257doc_ref_class(const char *cname)
258{
259 size_t clen = strlen(cname);
260 char *buf = alloca(clen + 4);
261 memcpy(buf, cname, clen);
262 buf[clen] = '\0';
263 for (char *p = buf; *p; ++p)
264 {
265 if (*p == '.')
266 *p = '_';
267 else
268 *p = tolower(*p);
269 }
270 memcpy(buf + clen, ".eo", sizeof(".eo"));
271 const char *eop = eina_hash_find(_filenames, buf);
272 if (!eop)
273 return;
274 eina_hash_set(_defereos, buf, eop);
275}
276
277static void
278doc_ref(Eo_Lexer *ls)
279{
280#if 0
281 const char *st = ls->stream, *ste = ls->stream_end;
282 size_t rlen = 0;
283 while ((st != ste) && ((*st == '.') || isalnum(*st)))
284 {
285 ++st;
286 ++rlen;
287 }
288 if ((rlen > 1) && (*(st - 1) == '.'))
289 --rlen;
290 if (!rlen)
291 return;
292 if (*ls->stream == '.')
293 return;
294
295 char *buf = alloca(rlen + 1);
296 memcpy(buf, ls->stream, rlen);
297 buf[rlen] = '\0';
298
299 /* actual full class name */
300 doc_ref_class(buf);
301
302 /* method name at the end */
303 char *end = strrchr(buf, '.');
304 if (!end)
305 return;
306 *end = '\0';
307 doc_ref_class(buf);
308
309 /* .get or .set at the end, handle possible property */
310 if (strcmp(end + 1, "get") && strcmp(end + 1, "set"))
311 return;
312 end = strrchr(buf, '.');
313 if (!end)
314 return;
315 *end = '\0';
316 doc_ref_class(buf);
317#else
318 (void)ls;
319#endif
320}
321
256static int 322static int
257doc_lex(Eo_Lexer *ls, Eina_Bool *term, Eina_Bool *since) 323doc_lex(Eo_Lexer *ls, Eina_Bool *term, Eina_Bool *since)
258{ 324{
@@ -324,6 +390,7 @@ doc_lex(Eo_Lexer *ls, Eina_Bool *term, Eina_Bool *since)
324 tokret = DOC_TEXT; 390 tokret = DOC_TEXT;
325 goto exit_with_token; 391 goto exit_with_token;
326 } 392 }
393 doc_ref(ls);
327 eina_strbuf_append_char(ls->buff, '@'); 394 eina_strbuf_append_char(ls->buff, '@');
328 next_char(ls); 395 next_char(ls);
329 /* in-class references */ 396 /* in-class references */
diff --git a/src/lib/eolian/eolian_database.c b/src/lib/eolian/eolian_database.c
index a897f9d5a6..6357c719cc 100644
--- a/src/lib/eolian/eolian_database.c
+++ b/src/lib/eolian/eolian_database.c
@@ -27,6 +27,8 @@ Eina_Hash *_declsf = NULL;
27Eina_Hash *_parsedeos = NULL; 27Eina_Hash *_parsedeos = NULL;
28Eina_Hash *_parsingeos = NULL; 28Eina_Hash *_parsingeos = NULL;
29 29
30Eina_Hash *_defereos = NULL;
31
30static int _database_init_count = 0; 32static int _database_init_count = 0;
31 33
32static void 34static void
@@ -58,6 +60,7 @@ database_init()
58 _declsf = eina_hash_stringshared_new(_hashlist_free); 60 _declsf = eina_hash_stringshared_new(_hashlist_free);
59 _parsedeos = eina_hash_string_small_new(NULL); 61 _parsedeos = eina_hash_string_small_new(NULL);
60 _parsingeos = eina_hash_string_small_new(NULL); 62 _parsingeos = eina_hash_string_small_new(NULL);
63 _defereos = eina_hash_string_small_new(NULL);
61 return ++_database_init_count; 64 return ++_database_init_count;
62} 65}
63 66
@@ -91,6 +94,7 @@ database_shutdown()
91 eina_hash_free(_declsf ); _declsf = NULL; 94 eina_hash_free(_declsf ); _declsf = NULL;
92 eina_hash_free(_parsedeos ); _parsedeos = NULL; 95 eina_hash_free(_parsedeos ); _parsedeos = NULL;
93 eina_hash_free(_parsingeos); _parsingeos = NULL; 96 eina_hash_free(_parsingeos); _parsingeos = NULL;
97 eina_hash_free(_defereos ); _defereos = NULL;
94 eina_shutdown(); 98 eina_shutdown();
95 } 99 }
96 return _database_init_count; 100 return _database_init_count;
diff --git a/src/lib/eolian/eolian_database.h b/src/lib/eolian/eolian_database.h
index 40a5f625ca..dd530c723e 100644
--- a/src/lib/eolian/eolian_database.h
+++ b/src/lib/eolian/eolian_database.h
@@ -53,6 +53,9 @@ extern Eina_Hash *_decls;
53extern Eina_Hash *_parsedeos; 53extern Eina_Hash *_parsedeos;
54extern Eina_Hash *_parsingeos; 54extern Eina_Hash *_parsingeos;
55 55
56/* for deferred dependency parsing */
57extern Eina_Hash *_defereos;
58
56typedef struct _Eolian_Object 59typedef struct _Eolian_Object
57{ 60{
58 const char *file; 61 const char *file;