--- trunk/KDE/kdebindings/kalyptus/kalyptusCxxToSmoke.pm	2008/08/07 09:53:13	843492
+++ trunk/KDE/kdebindings/kalyptus/kalyptusCxxToSmoke.pm	2008/08/07 09:53:21	843493
@@ -708,7 +708,10 @@
 			}
 		}
 
-		
+		if ($name eq 'self' && $m->{Flags} =~ "s") {
+			$classNode->AddProp( "Singleton", 1 );
+		}
+
 	    my $argId = 0;
 	    my $firstDefaultParam;
 	    foreach my $arg ( @{$m->{ParamList}} ) {
@@ -1726,8 +1729,12 @@
             $methodCode .= "private:\n";
             $methodCode .= "    $className *xthis;\n";
             $methodCode .= "public:\n";
-            $methodCode .= "    $xClassName\(void *x) : xthis(($className*)x) {}\n";
-            $switchCode .= "    $xClassName xtmp(obj), *xself = &xtmp;\n";
+            if ($classNode->{Singleton}) {
+                $switchCode .= "    $xClassName *xself = ($xClassName *) $className" . "::self();\n";
+            } else {
+                $methodCode .= "    $xClassName\(void *x) : xthis(($className*)x) {}\n";
+                $switchCode .= "    $xClassName xtmp(obj), *xself = &xtmp;\n";
+            }
         } else {
             $switchCode .= "    $xClassName *xself = ($xClassName*)obj;\n";
             $methodCode .= "public:\n";
