]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
Expose C enums and #defines in Python module.
authorMartin Belanger <martin.belanger@dell.com>
Mon, 11 Oct 2021 19:50:23 +0000 (15:50 -0400)
committerMartin Belanger <martin.belanger@dell.com>
Tue, 12 Oct 2021 13:09:05 +0000 (09:09 -0400)
Add persistent_set() method to the Python nvme_ctrl class.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
pynvme/nvme.i

index 919361727ff466a9a76d80b822fba2fc265e7bce..4e799909cdf7b4bcc4bd7e7260324f0fcbad2743 100644 (file)
@@ -297,6 +297,7 @@ struct nvme_ctrl {
   %immutable queue_count;
   %immutable serial;
   %immutable sqsize;
+  %immutable persistent;
   char *transport;
   char *subsysnqn;
   char *traddr;
@@ -309,6 +310,7 @@ struct nvme_ctrl {
   char *queue_count;
   char *serial;
   char *sqsize;
+  bool persistent;
 };
 
 struct nvme_ns {
@@ -520,6 +522,9 @@ struct nvme_ns {
   bool connected() {
     return nvme_ctrl_get_name($self) != NULL;
   }
+  void persistent_set(bool persistent) {
+    nvme_ctrl_set_persistent($self, persistent);
+  }
   void rescan() {
     nvme_rescan_ctrl($self);
   }
@@ -605,3 +610,15 @@ struct nvme_ns {
   }
 %};
 
+
+// We want to swig all the #define and enum from types.h, but none of the structs.
+%{
+#include "nvme/types.h"
+%}
+#define __attribute__(x)
+%rename($ignore, %$isclass) "";     // ignore all classes/structs
+%rename($ignore, %$isfunction) "";  // ignore all functions
+%rename($ignore, %$isunion) "";     // ignore all unions
+%rename($ignore, %$isvariable ) ""; // ignore all variables
+
+%include "../src/nvme/types.h"