Repository: lucy-clownfish
Updated Branches:
  refs/heads/master 7511e5c64 -> 978b013b1


Regenerate charmonizer.c

No functional change, sync only.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/c3a25ce3
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/c3a25ce3
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/c3a25ce3

Branch: refs/heads/master
Commit: c3a25ce3beff378b64ee93961d945d9ec2fe1bfd
Parents: 7511e5c
Author: Nick Wellnhofer <[email protected]>
Authored: Fri Jul 15 21:39:10 2016 +0200
Committer: Nick Wellnhofer <[email protected]>
Committed: Fri Jul 15 21:41:11 2016 +0200

----------------------------------------------------------------------
 compiler/common/charmonizer.c | 56 ++++++++++++++++++++++++++++++++------
 runtime/common/charmonizer.c  | 56 ++++++++++++++++++++++++++++++++------
 2 files changed, 94 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/c3a25ce3/compiler/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/compiler/common/charmonizer.c b/compiler/common/charmonizer.c
index 520148b..0ae21a2 100644
--- a/compiler/common/charmonizer.c
+++ b/compiler/common/charmonizer.c
@@ -650,8 +650,10 @@ typedef struct chaz_MakeVar chaz_MakeVar;
 typedef struct chaz_MakeRule chaz_MakeRule;
 typedef struct chaz_MakeBinary chaz_MakeBinary;
 
-typedef void (*chaz_Make_list_files_callback_t)(const char *dir, char *file,
-                                                void *context);
+typedef void
+(*chaz_Make_file_callback_t)(const char *dir, char *file, void *context);
+typedef int
+(*chaz_Make_file_filter_t)(const char *dir, char *file, void *context);
 
 /** Initialize the environment.
  *
@@ -685,7 +687,7 @@ chaz_Make_shell_type(void);
  */
 void
 chaz_Make_list_files(const char *dir, const char *ext,
-                     chaz_Make_list_files_callback_t callback, void *context);
+                     chaz_Make_file_callback_t callback, void *context);
 
 /** MakeFile constructor.
  */
@@ -849,6 +851,19 @@ chaz_MakeBinary_add_src_file(chaz_MakeBinary *self, const 
char *dir,
 void
 chaz_MakeBinary_add_src_dir(chaz_MakeBinary *self, const char *path);
 
+/** Add .c files in a directory as sources for the binary if they match
+ * a filter.
+ *
+ * @param path The path to the directory.
+ * @param filter A callback that is invoked for every source file. The
+ * source file is only added if the callback returns true. May be NULL.
+ * @param context Context passed to filter.
+ */
+void
+chaz_MakeBinary_add_filtered_src_dir(chaz_MakeBinary *self, const char *path,
+                                     chaz_Make_file_filter_t filter,
+                                     void *context);
+
 /** Add a prerequisite to the make rule of the binary.
  *
  * @param prereq The prerequisite.
@@ -4542,6 +4557,12 @@ struct chaz_MakeFile {
     size_t            num_binaries;
 };
 
+typedef struct {
+    chaz_MakeBinary         *binary;
+    chaz_Make_file_filter_t  filter;
+    void                    *filter_ctx;
+} chaz_MakeBinaryContext;
+
 /* Static vars. */
 static struct {
     char *make_command;
@@ -5491,6 +5512,14 @@ chaz_MakeBinary_add_src_file(chaz_MakeBinary *self, 
const char *dir,
 
 void
 chaz_MakeBinary_add_src_dir(chaz_MakeBinary *self, const char *path) {
+    chaz_MakeBinary_add_filtered_src_dir(self, path, NULL, NULL);
+}
+
+void
+chaz_MakeBinary_add_filtered_src_dir(chaz_MakeBinary *self, const char *path,
+                                     chaz_Make_file_filter_t filter,
+                                     void *filter_ctx) {
+    chaz_MakeBinaryContext context;
     size_t num_dirs = self->num_dirs;
     char **dirs = (char**)realloc(self->dirs, (num_dirs + 2) * sizeof(char*));
 
@@ -5499,18 +5528,27 @@ chaz_MakeBinary_add_src_dir(chaz_MakeBinary *self, 
const char *path) {
     self->dirs     = dirs;
     self->num_dirs = num_dirs + 1;
 
+    context.binary     = self;
+    context.filter     = filter;
+    context.filter_ctx = filter_ctx;
+
     chaz_Make_list_files(path, "c", S_chaz_MakeBinary_list_files_callback,
-                         self);
+                         &context);
 }
 
 static void
 S_chaz_MakeBinary_list_files_callback(const char *dir, char *file,
-                                      void *context) {
+                                      void *vcontext) {
+    chaz_MakeBinaryContext *context = (chaz_MakeBinaryContext*)vcontext;
     const char *dir_sep = chaz_OS_dir_sep();
-    char *path = chaz_Util_join(dir_sep, dir, file, NULL);
 
-    S_chaz_MakeBinary_do_add_src_file((chaz_MakeBinary*)context, path);
-    free(path);
+    if (context->filter == NULL
+        || context->filter(dir, file, context->filter_ctx) != 0
+       ) {
+        char *path = chaz_Util_join(dir_sep, dir, file, NULL);
+        S_chaz_MakeBinary_do_add_src_file(context->binary, path);
+        free(path);
+    }
 }
 
 static void
@@ -5600,7 +5638,7 @@ chaz_MakeBinary_get_link_flags(chaz_MakeBinary *self) {
 
 void
 chaz_Make_list_files(const char *dir, const char *ext,
-                     chaz_Make_list_files_callback_t callback, void *context) {
+                     chaz_Make_file_callback_t callback, void *context) {
     int         shell_type = chaz_OS_shell_type();
     const char *pattern;
     char       *command;

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/c3a25ce3/runtime/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.c b/runtime/common/charmonizer.c
index 27753cc..48a9b30 100644
--- a/runtime/common/charmonizer.c
+++ b/runtime/common/charmonizer.c
@@ -650,8 +650,10 @@ typedef struct chaz_MakeVar chaz_MakeVar;
 typedef struct chaz_MakeRule chaz_MakeRule;
 typedef struct chaz_MakeBinary chaz_MakeBinary;
 
-typedef void (*chaz_Make_list_files_callback_t)(const char *dir, char *file,
-                                                void *context);
+typedef void
+(*chaz_Make_file_callback_t)(const char *dir, char *file, void *context);
+typedef int
+(*chaz_Make_file_filter_t)(const char *dir, char *file, void *context);
 
 /** Initialize the environment.
  *
@@ -685,7 +687,7 @@ chaz_Make_shell_type(void);
  */
 void
 chaz_Make_list_files(const char *dir, const char *ext,
-                     chaz_Make_list_files_callback_t callback, void *context);
+                     chaz_Make_file_callback_t callback, void *context);
 
 /** MakeFile constructor.
  */
@@ -849,6 +851,19 @@ chaz_MakeBinary_add_src_file(chaz_MakeBinary *self, const 
char *dir,
 void
 chaz_MakeBinary_add_src_dir(chaz_MakeBinary *self, const char *path);
 
+/** Add .c files in a directory as sources for the binary if they match
+ * a filter.
+ *
+ * @param path The path to the directory.
+ * @param filter A callback that is invoked for every source file. The
+ * source file is only added if the callback returns true. May be NULL.
+ * @param context Context passed to filter.
+ */
+void
+chaz_MakeBinary_add_filtered_src_dir(chaz_MakeBinary *self, const char *path,
+                                     chaz_Make_file_filter_t filter,
+                                     void *context);
+
 /** Add a prerequisite to the make rule of the binary.
  *
  * @param prereq The prerequisite.
@@ -4542,6 +4557,12 @@ struct chaz_MakeFile {
     size_t            num_binaries;
 };
 
+typedef struct {
+    chaz_MakeBinary         *binary;
+    chaz_Make_file_filter_t  filter;
+    void                    *filter_ctx;
+} chaz_MakeBinaryContext;
+
 /* Static vars. */
 static struct {
     char *make_command;
@@ -5491,6 +5512,14 @@ chaz_MakeBinary_add_src_file(chaz_MakeBinary *self, 
const char *dir,
 
 void
 chaz_MakeBinary_add_src_dir(chaz_MakeBinary *self, const char *path) {
+    chaz_MakeBinary_add_filtered_src_dir(self, path, NULL, NULL);
+}
+
+void
+chaz_MakeBinary_add_filtered_src_dir(chaz_MakeBinary *self, const char *path,
+                                     chaz_Make_file_filter_t filter,
+                                     void *filter_ctx) {
+    chaz_MakeBinaryContext context;
     size_t num_dirs = self->num_dirs;
     char **dirs = (char**)realloc(self->dirs, (num_dirs + 2) * sizeof(char*));
 
@@ -5499,18 +5528,27 @@ chaz_MakeBinary_add_src_dir(chaz_MakeBinary *self, 
const char *path) {
     self->dirs     = dirs;
     self->num_dirs = num_dirs + 1;
 
+    context.binary     = self;
+    context.filter     = filter;
+    context.filter_ctx = filter_ctx;
+
     chaz_Make_list_files(path, "c", S_chaz_MakeBinary_list_files_callback,
-                         self);
+                         &context);
 }
 
 static void
 S_chaz_MakeBinary_list_files_callback(const char *dir, char *file,
-                                      void *context) {
+                                      void *vcontext) {
+    chaz_MakeBinaryContext *context = (chaz_MakeBinaryContext*)vcontext;
     const char *dir_sep = chaz_OS_dir_sep();
-    char *path = chaz_Util_join(dir_sep, dir, file, NULL);
 
-    S_chaz_MakeBinary_do_add_src_file((chaz_MakeBinary*)context, path);
-    free(path);
+    if (context->filter == NULL
+        || context->filter(dir, file, context->filter_ctx) != 0
+       ) {
+        char *path = chaz_Util_join(dir_sep, dir, file, NULL);
+        S_chaz_MakeBinary_do_add_src_file(context->binary, path);
+        free(path);
+    }
 }
 
 static void
@@ -5600,7 +5638,7 @@ chaz_MakeBinary_get_link_flags(chaz_MakeBinary *self) {
 
 void
 chaz_Make_list_files(const char *dir, const char *ext,
-                     chaz_Make_list_files_callback_t callback, void *context) {
+                     chaz_Make_file_callback_t callback, void *context) {
     int         shell_type = chaz_OS_shell_type();
     const char *pattern;
     char       *command;

Reply via email to