Enlightenment CVS committal

Author  : raster
Project : e17
Module  : libs/edje

Dir     : e17/libs/edje/src/lib


Modified Files:
        Makefile.am edje_load.c edje_private.h edje_program.c 
        edje_util.c 
Added Files:
        edje_match.c 


Log Message:


did some tests - this seems to be faster and seems to match correctly in some
test cases i brewed up. doesnt seem to break e so far and thats a fairly
comprehensive test.

===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/Makefile.am,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -3 -r1.37 -r1.38
--- Makefile.am 4 Nov 2007 09:53:29 -0000       1.37
+++ Makefile.am 18 Jan 2008 06:34:04 -0000      1.38
@@ -34,6 +34,7 @@
 edje_message_queue.c \
 edje_private.h \
 edje_cache.c \
+edje_match.c \
 edje_textblock_styles.c
 
 libedje_la_LIBADD       = -lm @EDJE_LIBS@ @fnmatch_libs@
===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/edje_load.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -3 -r1.110 -r1.111
--- edje_load.c 12 Sep 2007 17:42:21 -0000      1.110
+++ edje_load.c 18 Jan 2008 06:34:04 -0000      1.111
@@ -158,15 +158,16 @@
      {
        if (edf->collection_dir)
          {
-            Evas_List *l;
+             Edje_Patterns      *patterns;
 
-            for (l = edf->collection_dir->entries; l; l = l->next)
-              {
-                 Edje_Part_Collection_Directory_Entry *ce;
-
-                 ce = l->data;
-                 if (_edje_glob_match(ce->entry, glob)) return 1;
-              }
+             patterns = 
edje_match_collection_dir_init(edf->collection_dir->entries);
+             if (edje_match_collection_dir_exec(patterns,
+                                                glob))
+               {
+                  edje_match_patterns_free(patterns);
+                  return 1;
+               }
+             edje_match_patterns_free(patterns);
          }
        _edje_cache_file_unref(edf);
      }
===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/edje_private.h,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -3 -r1.135 -r1.136
--- edje_private.h      19 Oct 2007 19:31:42 -0000      1.135
+++ edje_private.h      18 Jan 2008 06:34:04 -0000      1.136
@@ -906,6 +906,48 @@
      EDJE_FILL_TYPE_TILE
 } Edje_Fill;
 
+typedef enum _Edje_Match_Error
+{
+   EDJE_MATCH_OK,
+     EDJE_MATCH_ALLOC_ERROR,
+     EDJE_MATCH_SYNTAX_ERROR
+     
+} Edje_Match_Error;
+
+typedef struct _Edje_Patterns   Edje_Patterns;
+struct _Edje_Patterns
+{
+   const char    **patterns;
+   size_t          patterns_size;
+   size_t          max_length;
+   size_t          finals[];
+   
+};
+
+Edje_Patterns   *edje_match_collection_dir_init(Evas_List *lst);
+Edje_Patterns   *edje_match_programs_signal_init(Evas_List *lst);
+Edje_Patterns   *edje_match_programs_source_init(Evas_List *lst);
+Edje_Patterns   *edje_match_callback_signal_init(Evas_List *lst);
+Edje_Patterns   *edje_match_callback_source_init(Evas_List *lst);
+
+int              edje_match_collection_dir_exec(const Edje_Patterns      *ppat,
+                                               const char               
*string);
+int              edje_match_programs_exec(const Edje_Patterns    *ppat_signal,
+                                         const Edje_Patterns    *ppat_source,
+                                         const char             *signal,
+                                         const char             *source,
+                                         Evas_List              *programs,
+                                         int (*func)(Edje_Program *pr, void 
*data),
+                                         void                   *data);
+int              edje_match_callback_exec(const Edje_Patterns    *ppat_signal,
+                                         const Edje_Patterns    *ppat_source,
+                                         const char             *signal,
+                                         const char             *source,
+                                         Evas_List              *callbacks,
+                                         Edje                   *ed);
+
+void             edje_match_patterns_free(Edje_Patterns *ppat);
+
 EAPI extern Eet_Data_Descriptor *_edje_edd_edje_file;
 EAPI extern Eet_Data_Descriptor *_edje_edd_edje_style;
 EAPI extern Eet_Data_Descriptor *_edje_edd_edje_style_tag;
@@ -998,7 +1040,6 @@
 void              _edje_text_class_hash_free(void);
 
 Edje             *_edje_fetch(Evas_Object *obj);
-int               _edje_glob_match(const char *str, const char *glob);
 int               _edje_freeze(Edje *ed);
 int               _edje_thaw(Edje *ed);
 int               _edje_block(Edje *ed);
===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/edje_program.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -3 -r1.54 -r1.55
--- edje_program.c      8 Sep 2007 18:31:56 -0000       1.54
+++ edje_program.c      18 Jan 2008 06:34:04 -0000      1.55
@@ -823,12 +823,46 @@
    _edje_message_send(ed, EDJE_QUEUE_SCRIPT, EDJE_MESSAGE_SIGNAL, 0, &emsg);
 }
 
+struct _Edje_Program_Data
+{
+#ifdef EDJE_PROGRAM_CACHE
+  Evas_List     *matches;
+  int            matched;
+#endif
+  Edje          *ed;
+  const char    *signal;
+  const char    *source;
+};
+
+static int _edje_glob_callback(Edje_Program *pr, void *dt)
+{
+   struct _Edje_Program_Data    *data = dt;
+
+#ifdef EDJE_PROGRAM_CACHE
+   data->matched++;
+#endif
+
+   _edje_program_run(data->ed, pr, 0, data->signal, data->source);
+   if (_edje_block_break(data->ed))
+     {
+#ifdef EDJE_PROGRAM_CACHE
+        evas_list_free(data->matches);
+        data->matches = NULL;
+#endif
+        return 1;
+     }
+
+#ifdef EDJE_PROGRAM_CACHE
+   data->matches = evas_list_append(data->matches, pr);
+#endif
+
+   return 0;
+}
+
 /* FIXME: what if we delete the evas object??? */
 void
 _edje_emit_handle(Edje *ed, const char *sig, const char *src)
 {
-   Evas_List *l;
-
    if (ed->delete_me) return;
    if (!sig) sig = "";
    if (!src) src = "";
@@ -883,35 +917,40 @@
 #endif
        if (!done)
          {
-#ifdef EDJE_PROGRAM_CACHE
-            int matched = 0;
-            Evas_List *matches = NULL;
-#endif
+             struct _Edje_Program_Data  data;
 
-            for (l = ed->collection->programs; l; l = l->next)
-              {
-                 Edje_Program *pr;
+             data.ed = ed;
+             data.source = src;
+             data.signal = sig;
+#ifdef EDJE_PROGRAM_CACHE
+            data.matched = 0;
+            data.matches = NULL;
+#endif
+             Edje_Patterns      *signals_patterns;
+             Edje_Patterns      *sources_patterns;
+
+             if (ed->collection->programs)
+               {
+                  signals_patterns = 
edje_match_programs_signal_init(ed->collection->programs);
+                  sources_patterns = 
edje_match_programs_source_init(ed->collection->programs);
+
+                  if (edje_match_programs_exec(signals_patterns,
+                                               sources_patterns,
+                                               sig,
+                                               src,
+                                               ed->collection->programs,
+                                               _edje_glob_callback,
+                                               &data) == 0)
+                    {
+                       edje_match_patterns_free(signals_patterns);
+                       edje_match_patterns_free(sources_patterns);
+                       goto break_prog;
+                    }
+
+                  edje_match_patterns_free(signals_patterns);
+                  edje_match_patterns_free(sources_patterns);
+               }
 
-                 pr = l->data;
-                 if ((_edje_glob_match(sig, pr->signal)) &&
-                     (_edje_glob_match(src, pr->source)))
-                   {
-#ifdef EDJE_PROGRAM_CACHE
-                      matched++;
-#endif
-                      _edje_program_run(ed, pr, 0, sig, src);
-                      if (_edje_block_break(ed))
-                        {
-#ifdef EDJE_PROGRAM_CACHE
-                           evas_list_free(matches);
-#endif
-                           goto break_prog;
-                        }
-#ifdef EDJE_PROGRAM_CACHE
-                      matches = evas_list_append(matches, pr);
-#endif
-                   }
-              }
 #ifdef EDJE_PROGRAM_CACHE
             if (tmps)
               {
@@ -920,7 +959,7 @@
                    evas_hash_add(ec->prog_cache.no_matches, tmps, ed);
                  else
                    ec->prog_cache.matches =
-                   evas_hash_add(ec->prog_cache.matches, tmps, matches);
+                   evas_hash_add(ec->prog_cache.matches, tmps, data.matches);
               }
 #endif
          }
@@ -940,25 +979,41 @@
 static void
 _edje_emit_cb(Edje *ed, const char *sig, const char *src)
 {
-   Evas_List *l;
+   Edje_Patterns        *signals_patterns;
+   Edje_Patterns        *sources_patterns;
+   Evas_List            *l;
 
    if (ed->delete_me) return;
    _edje_ref(ed);
    _edje_freeze(ed);
    _edje_block(ed);
    ed->walking_callbacks = 1;
-   for (l = ed->callbacks; l; l = l->next)
+
+   if (ed->callbacks)
      {
-       Edje_Signal_Callback *escb;
+        int     r;
+
+        signals_patterns = edje_match_callback_signal_init(ed->callbacks);
+        sources_patterns = edje_match_callback_source_init(ed->callbacks);
 
-       escb = l->data;
-       if ((!escb->just_added) &&
-           (!escb->delete_me) &&
-           (_edje_glob_match(sig, escb->signal)) &&
-           (_edje_glob_match(src, escb->source)))
-         escb->func(escb->data, ed->obj, sig, src);
-       if (_edje_block_break(ed)) goto break_prog;
+        r = edje_match_callback_exec(signals_patterns,
+                                     sources_patterns,
+                                     sig,
+                                     src,
+                                     ed->callbacks,
+                                     ed);
+
+        if (!r)
+          {
+             edje_match_patterns_free(signals_patterns);
+             edje_match_patterns_free(sources_patterns);
+             goto break_prog;
+          }
+
+        edje_match_patterns_free(signals_patterns);
+        edje_match_patterns_free(sources_patterns);
      }
+
    ed->walking_callbacks = 0;
    if ((ed->delete_callbacks) || (ed->just_added_callbacks))
      {
===================================================================
RCS file: /cvs/e/e17/libs/edje/src/lib/edje_util.c,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -3 -r1.102 -r1.103
--- edje_util.c 19 Oct 2007 19:31:42 -0000      1.102
+++ edje_util.c 18 Jan 2008 06:34:04 -0000      1.103
@@ -1951,20 +1951,6 @@
 }
 
 int
-_edje_glob_match(const char *str, const char *glob)
-{
-   if ((!glob) || (glob[0] == 0))
-     {
-       if ((!str) || (str[0] == 0)) return 1;
-       if ((glob) && (glob[0] == '*')) return 1;
-       return 0;
-     }
-   if (glob[0] == '*') return 1;
-   if ((glob) && (str) && (!fnmatch(glob, str, 0))) return 1;
-   return 0;
-}
-
-int
 _edje_freeze(Edje *ed)
 {
    ed->freeze++;



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to