summaryrefslogtreecommitdiffstats
path: root/xlators/experimental/jbr-client/src/gen-fops.py
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2016-04-04 14:55:20 +0530
committerJeff Darcy <jdarcy@redhat.com>2016-04-25 12:05:35 -0700
commit0a43265f1b10c35506fe82a525aa0fa43af6c0cd (patch)
tree42f27443ef5e4dc85b935cbfc1a8eb3f1d7a96b3 /xlators/experimental/jbr-client/src/gen-fops.py
parentc3353cdc4a3bcea416953af0585a08f33c5d4639 (diff)
nsr/jbr: Renaming nsr to jbr
As per community consensus, we have decided to rename nsr to jbr(Journal-Based-Replication). This is the patch to rename the "nsr" code to "jbr" Change-Id: Id2a9837f2ec4da89afc32438b91a1c302bb4104f BUG: 1328043 Signed-off-by: Avra Sengupta <asengupt@redhat.com> Reviewed-on: http://review.gluster.org/13899 Smoke: Gluster Build System <jenkins@build.gluster.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'xlators/experimental/jbr-client/src/gen-fops.py')
-rwxr-xr-xxlators/experimental/jbr-client/src/gen-fops.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/xlators/experimental/jbr-client/src/gen-fops.py b/xlators/experimental/jbr-client/src/gen-fops.py
new file mode 100755
index 00000000000..4d9451f7177
--- /dev/null
+++ b/xlators/experimental/jbr-client/src/gen-fops.py
@@ -0,0 +1,57 @@
+#!/usr/bin/python
+
+import os
+import re
+import string
+import sys
+
+curdir = os.path.dirname(sys.argv[0])
+gendir = os.path.join(curdir,'../../../../libglusterfs/src')
+sys.path.append(gendir)
+from generator import ops, fop_subs, cbk_subs, generate
+
+# We really want the callback argument list, even when we're generating fop
+# code, so we propagate here.
+# TBD: this should probably be right in generate.py
+for k, v in cbk_subs.iteritems():
+ fop_subs[k]['@ERROR_ARGS@'] = v['@ERROR_ARGS@']
+
+# Stolen from old codegen.py
+def load_templates (path):
+ templates = {}
+ tmpl_re = re.compile("/\* template-name (.*) \*/")
+ templates = {}
+ t_name = None
+ for line in open(path,"r").readlines():
+ if not line:
+ break
+ m = tmpl_re.match(line)
+ if m:
+ if t_name:
+ templates[t_name] = string.join(t_contents,'')
+ t_name = m.group(1).strip()
+ t_contents = []
+ elif t_name:
+ t_contents.append(line)
+ if t_name:
+ templates[t_name] = string.join(t_contents,'')
+ return templates
+
+# Stolen from gen_fdl.py
+def gen_client (templates):
+ for name, value in ops.iteritems():
+ if name == 'getspec':
+ # It's not real if it doesn't have a stub function.
+ continue
+ print generate(templates['cbk'],name,cbk_subs)
+ print generate(templates['cont-func'],name,fop_subs)
+ print generate(templates['fop'],name,fop_subs)
+
+tmpl = load_templates(sys.argv[1])
+for l in open(sys.argv[2],'r').readlines():
+ if l.find('#pragma generate') != -1:
+ print "/* BEGIN GENERATED CODE - DO NOT MODIFY */"
+ gen_client(tmpl)
+ print "/* END GENERATED CODE */"
+ else:
+ print l[:-1]