[Kde-bindings] KDE/kdebindings/csharp

Arno Rehn kde at arnorehn.de
Sun Aug 10 08:02:23 UTC 2008


SVN commit 844677 by arnorehn:

* If necessary, initialize additional bindings in the ScriptEngine.
* If the class with the name of the main assembly and in the namespace
  with the name of the parent directory is not found, look for classes that
  inherit from PlasmaScripting.Applet and choose the first one.

CCMAIL: kde-bindings at kde.org
  


 M  +6 -0      plasma/ChangeLog  
 M  +21 -0     plasma/src/PlasmaScriptengineKimono_Applet.cs  
 M  +4 -0      qyoto/src/SmokeInvocation.cs  


--- trunk/KDE/kdebindings/csharp/plasma/ChangeLog #844676:844677
@@ -1,3 +1,9 @@
+2008-08-09  Arno Rehn  <arno at arnorehn.de>
+* If necessary, initialize additional bindings in the ScriptEngine.
+* If the class with the name of the main assembly and in the namespace
+  with the name of the parent directory is not found, look for classes that
+  inherit from PlasmaScripting.Applet and choose the first one.
+
 2008-08-05  Richard Dale  <richard.j.dale at gmail.com>
 * Add some new plasma classes Plasma::Frame, Plasma::PaintUtils, 
   Plasma::PopupApplet, Plasma::Slider, Plasma::TabBar and 
--- trunk/KDE/kdebindings/csharp/plasma/src/PlasmaScriptengineKimono_Applet.cs #844676:844677
@@ -42,9 +42,30 @@
             QFileInfo program = new QFileInfo(MainScript());
 
             appletAssembly = Assembly.LoadFile(program.AbsoluteFilePath());
+            
+            // the newly loaded assembly might contain reference other bindings that need to be initialized
+            foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) {
+                // if the binding has already been initialized (e.g. in SmokeInvocation.InitRuntime()), continue.
+                if (SmokeInvocation.InitializedAssemblies.Contains(a)) continue;
+                AssemblySmokeInitializer attr = (AssemblySmokeInitializer) Attribute.GetCustomAttribute(a, typeof(AssemblySmokeInitializer));
+                if (attr != null) attr.CallInitSmoke();
+                SmokeInvocation.InitializedAssemblies.Add(a);
+            }
+            
             string typeName = Camelize(Package().Metadata().PluginName()) + ".";  // namespace
             typeName += Camelize(program.CompleteBaseName());
             appletType = appletAssembly.GetType(typeName);
+            if (appletType == null) {
+                foreach (Type t in appletAssembly.GetTypes()) {
+                    for (Type tmp = t.BaseType; tmp != null; tmp = tmp.BaseType) {
+                        if (tmp == typeof(PlasmaScripting.Applet)) {
+                            appletType = t;
+                            break;
+                        }
+                    }
+                    if (appletType != null) break;
+                }
+            }
 
             applet = (PlasmaScripting.Applet) Activator.CreateInstance(appletType, new object[] { this });
             applet.Init();
--- trunk/KDE/kdebindings/csharp/qyoto/src/SmokeInvocation.cs #844676:844677
@@ -415,6 +415,9 @@
 			}
 		}
 
+		// list of assemblies on which CallInitSmoke() has already been called.
+		public static List<Assembly> InitializedAssemblies = new List<Assembly>();
+		// whether the qyoto (core) runtime has been initialized
 		static bool runtimeInitialized = false;
 
 		public static void InitRuntime() {
@@ -427,6 +430,7 @@
 			foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) {
 				AssemblySmokeInitializer attr = (AssemblySmokeInitializer) Attribute.GetCustomAttribute(a, typeof(AssemblySmokeInitializer));
 				if (attr != null) attr.CallInitSmoke();
+				InitializedAssemblies.Add(a);
 			}
 			runtimeInitialized = true;
 		}



More information about the Kde-bindings mailing list