Fix #7297 - filter objects on roo
authorAlan <alan@roojs.com>
Wed, 6 Jul 2022 07:35:45 +0000 (15:35 +0800)
committerAlan <alan@roojs.com>
Wed, 6 Jul 2022 07:35:45 +0000 (15:35 +0800)
src/Palete/Gir.vala
src/Palete/GirObject.vala
src/Palete/Roo.vala

index ad708ea..eed7cf7 100644 (file)
@@ -243,14 +243,18 @@ namespace Palete {
                        if (type.length < 1 || type.contains(".")) {
                                return "null";
                        }
-                       switch(type) {
+                       switch(type.down()) {
+                               case "boolean":
+                               case "bool":
                                case "gboolean":
                                        return "true";
+                               case "int":                                     
                                case "guint":
                                        return "0";
                                case "gdouble":
                                        return "0f";
                                case "utf8":
+                               case "string":
                                        return "\"\"";
                                default:
                                        return "?"+  type + "?";
index 0554592..21c9377 100644 (file)
@@ -447,10 +447,18 @@ namespace Palete {
                        
                        // does not handle Enums... - no need to handle anything else.
                        var def = this.type.contains(".") ?  "" :  Gir.guessDefaultValueForType(this.type);
-                       if (this.type.contains(".") || this.type.down() == "function") {
+                       if (this.type.contains(".") ) {
                                return  new JsRender.NodeProp.raw(this.name, this.type, def);
                        }
-                       
+                       if (this.type.down() == "function"  ) {
+                               return  new JsRender.NodeProp.raw(this.name, this.type, "function()\n{\n\n}");
+                       }
+                       if (this.type.down() == "array"  ) {
+                               return  new JsRender.NodeProp.raw(this.name, this.type, "[\n\n]");
+                       }
+                       if (this.type.down() == "object"  ) {
+                               return  new JsRender.NodeProp.raw(this.name, this.type, "{\n\n}");
+                       }
                        return  new JsRender.NodeProp.prop(this.name, this.type, def); // signature?
                
                }
index 737501e..978f6f5 100644 (file)
@@ -248,7 +248,7 @@ namespace Palete {
                                
                                
                                case JsRender.NodePropType.PROP:
-                                       return cls.props;
+                                       return  this.filterProps(cls.props);
                                case JsRender.NodePropType.LISTENER:
                                        return cls.signals;
                                case JsRender.NodePropType.METHOD:
@@ -268,6 +268,44 @@ namespace Palete {
 
                         
                }
+               
+               
+               public Gee.HashMap<string,GirObject>  filterProps(Gee.HashMap<string,GirObject> props)
+               {
+                       // we shold probably cache this??
+                       
+                       var outprops = new Gee.HashMap<string,GirObject>(); 
+                       
+                       foreach(var k in props.keys) {
+                               var val = props.get(k);
+                               
+                               // special props..
+                               switch(k) {
+                                       case "listeners" : 
+                                               continue;
+                                       default:
+                                               break;
+                               }
+                               
+                                
+                               if (!val.type.contains(".")) {
+                                       outprops.set(k,val);
+                                       continue;
+                               }
+                               
+                               
+                                
+                               // do nothing? - classes not allowed?
+                               
+                       }
+                       
+                       
+                       return outprops;
+               
+               
+               }
+               
+               
                public string[] getInheritsFor(string ename)
                {
                        string[] ret = {};