{
// overrides should be in a file Gir.overides
// in that "Gtk.Label.new.str" : "label"
+
loadOverrides();
var key = "%s.%s.%s".printf(cls,method,param);
//print("Chekcing for key %s\n", key);
}
- public static void loadOverrides(bool force = false)
+ public static void loadOverrides(bool force = false)
{
if (overrides_loaded && ! force) {
return;
}
-
+ Json.Node node = null;
var pa = new Json.Parser();
- pa.load_from_file(BuilderApplication.configDirectory() + "/resources/Gir.overides");
- var node = pa.get_root();
-
- if (node.get_node_type () != Json.NodeType.OBJECT) {
- throw new GirError.INVALID_FORMAT ("Error loading gir.overides : Unexpected element type %s", node.type_name ());
+ try {
+ pa.load_from_file(BuilderApplication.configDirectory() + "/resources/Gir.overides");
+ node = pa.get_root();
+ if (node.get_node_type () != Json.NodeType.OBJECT) {
+ GLib.debug("Error loading gir.overides : Unexpected element type %s", node.type_name ());
+
+ return;
+ //throw new GirError.INVALID_FORMAT ("Error loading gir.overides : Unexpected element type %s", node.type_name ());
+ }
+ } catch (GLib.Error e) {
+ return;
}
+
overrides = new Gee.HashMap<string,string>();
*
*/
- public static Gee.HashMap<string,Gir> global_cache = null;
+ // public static Gee.HashMap<string,Gir> global_cache = null;
- public static Gir? factory(Project.Project project, string ns)
+ public static GirObject? factory(Project.Project? project, string ns)
{
- if (global_cache == null) {
- global_cache = new Gee.HashMap<string,Gir>();
+
+ if (project == null) {
+ return null;
+ }
+ if (project.gir_cache == null) {
+ project.gir_cache = new Gee.HashMap<string,GirObject>();
}
- var cache = global_cache;
+ var cache = project.gir_cache;
if (project != null && project is Project.Gtk) {
var gproj = ((Project.Gtk)project);
if (!gproj.gir_cache_loaded) {
var fqn = in_fqn;
// swap Gtk.Source* to GtkSource.
- GLib.debug("Gir.facotryFqn search %s", fqn);
+ //GLib.debug("Gir.factoryFqn search %s", fqn);
var bits = fqn.split(".");
if (bits.length < 1) {
+ //GLib.debug("Gir.factoryFqn fail - missing '.'");
return null;
}
var f = (GirObject)factory(project , bits[0]);
if (bits.length == 1 || f ==null) {
+ //GLib.debug("Gir.factoryFqn fail - factory failed to load NS");
return f;
}
+ //GLib.debug("Gir.factoryFqn fetching child %s", fqn.substring(bits[0].length+1));
return f.fetchByFqn(fqn.substring(bits[0].length+1)); // since classes are stored in fqn format...?
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 + "?";