ISAFunctions.__init__(self)
self.pages_written = []
- def write_pysource(self, pagename):
+ def write_code(self, pagename, ext):
self.pages_written.append(pagename)
function = self.fns[pagename]
isadir = get_isafn_src_dir()
os.makedirs(isadir, exist_ok=True)
- fname = os.path.join(isadir, "%s.py" % pagename)
+ fname = os.path.join(isadir, (pagename + ext))
sourcecache = dict()
check_in_gitignore(fname)
with open(fname, "w") as f:
def pyfnwriter():
isa = PyISAFnWriter()
write_isa_class = True
- if len(sys.argv) == 1: # quick way to do it
+ args = dict.fromkeys(sys.argv[1:])
+ ext = ".py"
+ if "--c" in args:
+ ext = ".c"
+ del args["--c"]
+ if len(args) == 0: # quick way to do it
log(dir(isa))
sources = isa.fns.keys()
else:
- sources = sys.argv[1:]
+ sources = list(args)
if sources[0] == "noall": # don't rewrite all.py
write_isa_class = False
sources.pop(0)
+ if ext == ".c":
+ raise NotImplementedError("C mode is not supported yet")
log("sources", write_isa_class, sources)
for source in sources:
- isa.write_pysource(source)
+ isa.write_code(pagename=source, ext=ext)
if write_isa_class:
isa.write_isa_class()