r26658: pidl: Register Python modules.
[ira/wip.git] / source / pidl / lib / Parse / Pidl / Samba4 / Python.pm
index 4110a94dfdaaa24855e76c9eb65af70e773166b9..68e35a85324f3ff2051b71f913ff6a0bcdd09dfd 100644 (file)
@@ -54,7 +54,7 @@ sub Parse($$$$)
     my($self,$basename,$ndr,$hdr) = @_;
     
     my $py_hdr = $hdr;
-    $py_hdr =~ s/^/py_/g;
+    $py_hdr =~ s/ndr_([^\/]+)$/py_$1/g;
 
     $self->pidl_hdr("/* header auto-generated by pidl */\n\n");
        
@@ -66,10 +66,20 @@ sub Parse($$$$)
 #include \"$py_hdr\"
 
 ");
+       
+       $self->pidl("static PyMethodDef $basename\_methods[] = {");
+       $self->indent;
+       $self->pidl("{ NULL, NULL, 0, NULL }");
+       $self->deindent;
+       $self->pidl("};");
+
+       $self->pidl("");
 
        $self->pidl("void init$basename(void)");
        $self->pidl("{");
        $self->indent;
+       $self->pidl("PyObject *m;");
+       $self->pidl("m = Py_InitModule((char *)\"$basename\", $basename\_methods);");
        # FIXME
        $self->deindent;
        $self->pidl("}");