Repository: lucy-clownfish
Updated Branches:
  refs/heads/master 978b013b1 -> 0bacc88bf


Add "installed" property to .cfp

CFP files can specify whether .cfh files for a parcel should be
installed system-wide or not.


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

Branch: refs/heads/master
Commit: 3e225d4a2ea12e800305e7152e98ac670a645120
Parents: f0abe45
Author: Nick Wellnhofer <wellnho...@aevum.de>
Authored: Fri Jul 15 14:18:45 2016 +0200
Committer: Nick Wellnhofer <wellnho...@aevum.de>
Committed: Fri Jul 15 22:09:57 2016 +0200

----------------------------------------------------------------------
 compiler/src/CFCParcel.c | 28 ++++++++++++++++++++++------
 compiler/src/CFCParcel.h |  3 +++
 2 files changed, 25 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3e225d4a/compiler/src/CFCParcel.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCParcel.c b/compiler/src/CFCParcel.c
index 95d093e..23bd7fd 100644
--- a/compiler/src/CFCParcel.c
+++ b/compiler/src/CFCParcel.c
@@ -40,6 +40,7 @@ struct CFCParcel {
     char *Prefix;
     char *PREFIX;
     char *privacy_sym;
+    int is_installed;
     int is_required;
     char **inherited_parcels;
     size_t num_inherited_parcels;
@@ -197,7 +198,8 @@ CFCParcel_init(CFCParcel *self, const char *name, const 
char *nickname,
     self->privacy_sym[privacy_sym_len] = '\0';
 
     // Initialize flags.
-    self->is_required = false;
+    self->is_installed = false;
+    self->is_required  = false;
 
     // Initialize arrays.
     self->inherited_parcels = (char**)CALLOCATE(1, sizeof(char*));
@@ -219,11 +221,12 @@ S_new_from_json(const char *json, const char *path, 
CFCFileSpec *file_spec) {
     if (CFCJson_get_type(parsed) != CFCJSON_HASH) {
         CFCUtil_die("Parcel definition must be a hash in '%s'", path);
     }
-    const char  *name     = NULL;
-    const char  *nickname = NULL;
-    CFCVersion  *version  = NULL;
-    CFCJson     *prereqs  = NULL;
-    CFCJson    **children = CFCJson_get_children(parsed);
+    const char  *name      = NULL;
+    const char  *nickname  = NULL;
+    int          installed = true;
+    CFCVersion  *version   = NULL;
+    CFCJson     *prereqs   = NULL;
+    CFCJson    **children  = CFCJson_get_children(parsed);
     for (size_t i = 0; children[i]; i += 2) {
         const char *key = CFCJson_get_string(children[i]);
         CFCJson *value = children[i + 1];
@@ -241,6 +244,13 @@ S_new_from_json(const char *json, const char *path, 
CFCFileSpec *file_spec) {
             }
             nickname = CFCJson_get_string(value);
         }
+        else if (strcmp(key, "installed") == 0) {
+            if (value_type != CFCJSON_BOOL) {
+                CFCUtil_die("'installed' must be a boolean (filepath %s)",
+                            path);
+            }
+            installed = CFCJson_get_bool(value);
+        }
         else if (strcmp(key, "version") == 0) {
             if (value_type != CFCJSON_STRING) {
                 CFCUtil_die("'version' must be a string (filepath %s)",
@@ -267,6 +277,7 @@ S_new_from_json(const char *json, const char *path, 
CFCFileSpec *file_spec) {
         CFCUtil_die("Missing required key 'version' (filepath '%s')", path);
     }
     CFCParcel *self = CFCParcel_new(name, nickname, version, file_spec);
+    self->is_installed = installed;
     if (prereqs) {
         S_set_prereqs(self, prereqs, path);
     }
@@ -364,6 +375,11 @@ CFCParcel_get_nickname(CFCParcel *self) {
     return self->nickname;
 }
 
+int
+CFCParcel_is_installed(CFCParcel *self) {
+    return self->is_installed;
+}
+
 CFCVersion*
 CFCParcel_get_version(CFCParcel *self) {
     return self->version;

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3e225d4a/compiler/src/CFCParcel.h
----------------------------------------------------------------------
diff --git a/compiler/src/CFCParcel.h b/compiler/src/CFCParcel.h
index 9ecec9b..e70b73d 100644
--- a/compiler/src/CFCParcel.h
+++ b/compiler/src/CFCParcel.h
@@ -88,6 +88,9 @@ CFCParcel_get_name(CFCParcel *self);
 const char*
 CFCParcel_get_nickname(CFCParcel *self);
 
+int
+CFCParcel_is_installed(CFCParcel *self);
+
 struct CFCVersion*
 CFCParcel_get_version(CFCParcel *self);
 

Reply via email to