<pre style='margin:0'>
Clemens Lang (neverpanic) pushed a commit to branch gsoc17-migrate
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/b6c4cd93b2867a73e5f0c1df5919466365b969c4">https://github.com/macports/macports-base/commit/b6c4cd93b2867a73e5f0c1df5919466365b969c4</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit b6c4cd93b2867a73e5f0c1df5919466365b969c4
</span>Author: Umesh Singla <umeshksingla@macports.org>
AuthorDate: Thu Aug 10 23:17:33 2017 +0530
<span style='display:block; white-space:pre;color:#404040;'> WIP: Add utility functions for snapshot entity
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Add Tcl-C interface functions for registry::snapshot entity
</span>---
src/cregistry/entry.c | 14 +++++++++++---
src/cregistry/entry.h | 1 +
src/registry2.0/entry.c | 2 +-
src/registry2.0/util.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
src/registry2.0/util.h | 6 ++++++
5 files changed, 66 insertions(+), 4 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/cregistry/entry.c b/src/cregistry/entry.c
</span><span style='display:block; white-space:pre;color:#808080;'>index 80a37db..e96cf79 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/cregistry/entry.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/cregistry/entry.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1713,9 +1713,17 @@ int reg_snapshot_get(reg_registry* reg, char* id, reg_snapshot* snapshot, reg_er
</span>
if (r == SQLITE_DONE) {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- (*snapshot)->id = NULL;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- (*snapshot)->note = NULL;
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- (*snapshot)->ports = result;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ reg_snapshot* s = malloc(sizeof(reg_snapshot*));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (!s) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return -1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ s->id = NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ s->note = NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ s->proc = NULL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ s->ports = result;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *snapshot = s;
</span>
return result_count;
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/cregistry/entry.h b/src/cregistry/entry.h
</span><span style='display:block; white-space:pre;color:#808080;'>index ca3cc46..862d249 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/cregistry/entry.h
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/cregistry/entry.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -58,6 +58,7 @@ typedef struct {
</span> char* id;
char* note;
port* ports;
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ char* proc; /* name of Tcl proc, if using Tcl */
</span> } reg_snapshot;
reg_entry* reg_entry_create(reg_registry* reg, char* name, char* version,
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/registry2.0/entry.c b/src/registry2.0/entry.c
</span><span style='display:block; white-space:pre;color:#808080;'>index e5b123c..2700945 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/registry2.0/entry.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/registry2.0/entry.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -518,7 +518,7 @@ static int get_snapshot(Tcl_Interp* interp, int objc, Tcl_Obj* CONST objv[]) {
</span> reg_error error;
reg_snapshot* snapshot;
int port_count = reg_snapshot_get(reg, id, &snapshot, &error);
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if (snapshot != NULL) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (snapshot != NULL && port_count >= 0) {
</span> Tcl_Obj* resultObj;
if (entry_to_obj(interp, &resultObj, snapshot, NULL, &error)) {
Tcl_SetObjResult(interp, resultObj);
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/registry2.0/util.c b/src/registry2.0/util.c
</span><span style='display:block; white-space:pre;color:#808080;'>index 3edd752..705d869 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/registry2.0/util.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/registry2.0/util.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -191,6 +191,29 @@ int set_entry(Tcl_Interp* interp, char* name, reg_entry* entry,
</span> }
/**
<span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Sets a given name to be an snapshot object.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * @param [in] interp Tcl interpreter to create the snapshot within
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * @param [in] name name to associate the given snapshot with
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * @param [in] snapshot snapshot to associate with the given name
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * @param [out] errPtr description of error if it couldn't be set
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * @return true if success; false if failure
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * @see set_object
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int set_snapshot(Tcl_Interp* interp, char* name, reg_snapshot* snapshot,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ reg_error* errPtr) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (set_object(interp, name, snapshot, "snapshot", snapshot_obj_cmd, NULL,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ errPtr)) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ snapshot->proc = strdup(name);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (!snapshot->proc) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/**
</span> * Sets a given name to be a file object.
*
* @param [in] interp Tcl interpreter to create the file within
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -303,6 +326,23 @@ int entry_to_obj(Tcl_Interp* interp, Tcl_Obj** obj, reg_entry* entry,
</span> return 1;
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+int snapshot_to_obj(Tcl_Interp* interp, Tcl_Obj** obj, reg_snapshot* snapshot,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int* lower_bound, reg_error* errPtr) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (snapshot->proc == NULL) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ char* name = unique_name(interp, "::registry::snapshot", lower_bound);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (!name) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (!set_snapshot(interp, name, entry, errPtr)) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ free(name);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ free(name);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *obj = Tcl_NewStringObj(snapshot->proc, -1);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> int file_to_obj(Tcl_Interp* interp, Tcl_Obj** obj, reg_file* file,
int* lower_bound, reg_error* errPtr) {
if (file->proc == NULL) {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -344,6 +384,13 @@ int list_entry_to_obj(Tcl_Interp* interp, Tcl_Obj*** objs,
</span> (void***)objs, (void**)entries, entry_count, errPtr);
}
<span style='display:block; white-space:pre;background:#e0ffe0;'>+int list_snapshot_to_obj(Tcl_Interp* interp, Tcl_Obj*** objs,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ reg_snapshot** snapshots, int snapshot_count, reg_error* errPtr) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int lower_bound = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return recast(interp, (cast_function*)snapshot_to_obj, &lower_bound, NULL,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ (void***)objs, (void**)snapshots, snapshot_count, errPtr);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> int list_file_to_obj(Tcl_Interp* interp, Tcl_Obj*** objs,
reg_file** files, int file_count, reg_error* errPtr) {
int lower_bound = 0;
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/registry2.0/util.h b/src/registry2.0/util.h
</span><span style='display:block; white-space:pre;color:#808080;'>index c990591..2b07d39 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/registry2.0/util.h
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/registry2.0/util.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -58,6 +58,8 @@ int set_object(Tcl_Interp* interp, char* name, void* value, char* type,
</span> Tcl_ObjCmdProc* proc, Tcl_CmdDeleteProc* deleteProc, reg_error* errPtr);
int set_entry(Tcl_Interp* interp, char* name, reg_entry* entry,
reg_error* errPtr);
<span style='display:block; white-space:pre;background:#e0ffe0;'>+int set_snapshot(Tcl_Interp* interp, char* name, reg_snapshot* snapshot,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ reg_error* errPtr);
</span> int set_file(Tcl_Interp* interp, char* name, reg_file* file,
reg_error* errPtr);
int set_portgroup(Tcl_Interp* interp, char* name, reg_portgroup* portgroup,
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -75,6 +77,10 @@ int entry_to_obj(Tcl_Interp* interp, Tcl_Obj** obj, reg_entry* entry,
</span> int* lower_bound, reg_error* errPtr);
int list_entry_to_obj(Tcl_Interp* interp, Tcl_Obj*** objs,
reg_entry** entries, int entry_count, reg_error* errPtr);
<span style='display:block; white-space:pre;background:#e0ffe0;'>+int snapshot_to_obj(Tcl_Interp* interp, Tcl_Obj** obj, reg_snapshot* snapshot,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int* lower_bound, reg_error* errPtr);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int list_snapshot_to_obj(Tcl_Interp* interp, Tcl_Obj*** objs,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ reg_snapshot** snapshots, int snapshot_count, reg_error* errPtr);
</span> int file_to_obj(Tcl_Interp* interp, Tcl_Obj** ibj, reg_file* file,
int* lower_bound, reg_error* errPtr);
int list_file_to_obj(Tcl_Interp* interp, Tcl_Obj*** objs,
</pre><pre style='margin:0'>
</pre>