]> git.draconx.ca Git - upkg.git/commitdiff
upkg: Resolve hierarchical object references.
authorNick Bowler <nbowler@draconx.ca>
Thu, 3 Mar 2011 01:22:53 +0000 (20:22 -0500)
committerNick Bowler <nbowler@draconx.ca>
Sun, 13 Mar 2011 21:38:59 +0000 (17:38 -0400)
This doesn't actually do anything useful yet, but it's a start.

src/upkg.c

index a82ab2c355764e3e683294c44a8c68bbd18ce82a..038eb39fe9ce410921abbad8134f5e180536fdb4 100644 (file)
@@ -290,28 +290,54 @@ int package_export(struct upkg *pkg)
 
 static int process_object(int mode, const char *objname)
 {
+       char work[strlen(objname)+1], *p = work, *c;
        GTypeModule *pkg;
+       long current = -1;
        int ret = 0;
 
-       pkg = u_pkg_open(objname);
+       strcpy(work, objname);
+
+       /* First, find and open the actual package. */
+       c = strchr(p, '.');
+       if (c) *c = 0;
+
+       pkg = u_pkg_open(p);
        if (!pkg || !g_type_module_use(pkg)) {
                fprintf(stderr, "%s: %s: failed to open package.\n",
-                               progname, objname);
+                               progname, work);
                goto out;
        }
 
        if (!U_PKG(pkg)->pkg) {
                if (u_pkg_is_native(pkg)) {
                        fprintf(stderr, "%s: %s: not a UObject package.\n",
-                                       progname, objname);
+                                       progname, work);
                } else {
                        fprintf(stderr, "%s: %s: package not found.\n",
-                                       progname, objname);
+                                       progname, work);
                }
 
                goto out_unuse;
        }
 
+       /* Resolve the hierarchical reference. */
+       while (c) {
+               p = c+1;
+               c = strchr(p, '.');
+               if (c) *c = 0;
+
+               current = upkg_export_find(U_PKG(pkg)->pkg, current, p);
+               if (current == -1) {
+                       /* We want to print the full name up to this point. */
+                       strcpy(work, objname);
+                       if (c) *c = 0;
+
+                       fprintf(stderr, "%s: %s: object not found.\n",
+                                       progname, work);
+                       goto out_unuse;
+               }
+       }
+
        switch (mode) {
        case MODE_INFO:
                ret = package_info(U_PKG(pkg)->pkg);