]> git.draconx.ca Git - gob-dx.git/blobdiff - src/checks.c
Replace gnulib patch with new common helper macro.
[gob-dx.git] / src / checks.c
index b30d0f8122c8cf9a292b0078f9b76ba957f0ab2b..bd6c8e79f02ba190284e36d39ab115d4d12f399d 100644 (file)
@@ -1,7 +1,7 @@
 /* GOB C Preprocessor
  * Copyright (C) 1999-2000 the Free Software Foundation.
  * Copyright (C) 2000 Eazel, Inc.
- * Copyright (C) 2001 George Lebl
+ * Copyright (C) 2001-2004 George Lebl
  *
  * Author: George Lebl
  *
@@ -21,7 +21,7 @@
  * USA.
  */
 
-#include "config.h"
+#include <config.h>
 #include <string.h>
 #include <stdio.h>
 #include <glib.h>
@@ -195,10 +195,12 @@ check_duplicate_named (Class *c, Node *node, const char *id, int line_no)
                } else {
                        continue;
                }
-               if (n == node ||
-                   line_no >= nline_no ||
-                   g_strcasecmp (nid, id) != 0)
+
+               if (n == node || line_no >= nline_no
+                   || gob_strcasecmp (nid, id) != 0)
+               {
                        continue;
+               }
                error_printf (GOB_ERROR, nline_no,
                              "named symbol (argument or signal) '%s' "
                              "redefined, first defined on line %d "
@@ -334,6 +336,19 @@ check_signal_args (Class *c)
                                continue;
 
                        for (l = m->gtktypes; l != NULL; l = l->next) {
+                               if (strcmp (l->data, "BOXED") == 0) {
+                                       error_printf (GOB_ERROR, m->line_no,
+                                                     "BOXED not allowed as "
+                                                     "a signal argument, use "
+                                                     "POINTER, or BOXED_*");
+                                       continue;
+                               } else if (strcmp (l->data, "FLAGS") == 0) {
+                                       error_printf (GOB_ERROR, m->line_no,
+                                                     "FLAGS not allowed as "
+                                                     "a signal argument, use "
+                                                     "UINT");
+                                       continue;
+                               }
                                if (get_cast (l->data, FALSE))
                                        continue;
                                error_printf (GOB_ERROR, m->line_no,
@@ -465,6 +480,50 @@ check_func_arg_checks(Class *c)
        }
 }
 
+void
+check_func_attrs(Class *c)
+{
+  GList *li;
+  for (li = c->nodes; li != NULL; li = li->next) {
+    Node *n = li->data;
+    if (n->type == METHOD_NODE) {
+      Method *m = (Method *)n;
+      if ((m->method == INIT_METHOD ||
+          m->method == CLASS_INIT_METHOD)
+         && (m->funcattrs != NULL && strlen(m->funcattrs) != 0)) {
+       /* This is actually dead code at the moment, since the parser
+          doesn't accept attributes to the init or class_init
+          syntactic forms anyway.  But it could easily be made to do
+          so, and also for virtual override and signal methods, and
+          then we could give kinder error messages here.  */
+       error_print (GOB_ERROR, m->line_no,
+                    "function attributes (G_GNUC_PRINTF, etc.) aren't "
+                     "supported for the init or class_init methods");
+      }
+    }
+  }
+}
+
+void
+check_for_class_destructors (Class *c)
+{
+       GList *li;
+       for (li = c->nodes; li != NULL; li = li->next) {
+               Node *n = li->data;
+               if (n->type == VARIABLE_NODE) {
+                       Variable *v = (Variable *)n;
+                       if (v->destructor != NULL &&
+                           v->scope == CLASS_SCOPE) {
+                               error_print (GOB_WARN, v->line_no,
+                                            "classwide members cannot have "
+                                            "destructors since the classes "
+                                            "are static and never get "
+                                            "destroyed anyway");
+                       }
+               }
+       }
+}
+
 int
 count_signals(Class *c)
 {
@@ -601,7 +660,8 @@ count_unreftors (Class *c)
                if (n->type == VARIABLE_NODE) {
                        Variable *v = (Variable *)n;
                        if (v->destructor != NULL &&
-                           v->destructor_unref)
+                           v->destructor_unref &&
+                           v->scope != CLASS_SCOPE)
                                num++;
                }
        }
@@ -618,7 +678,8 @@ count_destructors (Class *c)
                if (n->type == VARIABLE_NODE) {
                        Variable *v = (Variable *)n;
                        if (v->destructor != NULL &&
-                           ! v->destructor_unref)
+                           ! v->destructor_unref &&
+                           v->scope != CLASS_SCOPE)
                                num++;
                }
        }
@@ -641,6 +702,22 @@ count_initializers (Class *c)
        return num;
 }
 
+int
+count_glade_widgets (Class *c)
+{
+       int num = 0;
+       GList *li;
+       for (li = c->nodes; li != NULL; li = li->next) {
+               Node *n = li->data;
+               if (n->type == VARIABLE_NODE) {
+                       Variable *v = (Variable *)n;
+                       if (v->glade_widget)
+                               num++;
+               }
+       }
+       return num;
+}
+
 gboolean
 find_get_type (Class *c)
 {