[gjs/wip/gobj-kitchen-sink: 18/19] GDBus: Allow prefixing property names with 'DBus' to help prevent collisions



commit 3a7a934d8b479e418c0e90eb409d687f5112c4d1
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Jan 27 11:09:20 2012 -0500

    GDBus: Allow prefixing property names with 'DBus' to help prevent collisions
    
    Some implementers of DBus interfaces may be asked to implement properties
    called 'Name' or 'Interface', which would collide with our own uses of
    these functions. Allow these implementers to provide 'DBusName' or
    'DBusInterface' instead.

 modules/overrides/Gio.js |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/modules/overrides/Gio.js b/modules/overrides/Gio.js
index e86a5e7..6928a5c 100644
--- a/modules/overrides/Gio.js
+++ b/modules/overrides/Gio.js
@@ -381,7 +381,14 @@ const DBusImplementerBase = new Lang.Class({
 	let klass = this.constructor;
 
 	let propInfo = klass.Interface.lookup_property(property_name);
-	let jsval = this[property_name];
+
+        // Properties like "Name" may collide with regular class usage,
+        // so try prefixing with "DBus" first.
+        let jsval;
+        jsval = this['DBus' + property_name];
+        if (jsval === undefined)
+            jsval = this[property_name];
+
 	if (jsval != undefined)
 	    return GLib.Variant.new(propInfo.signature, jsval);
 	else



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]