[beast: 6/70] V8BSE: V8Stub.py: add skeleton for language binding generation
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 6/70] V8BSE: V8Stub.py: add skeleton for language binding generation
- Date: Tue, 28 Mar 2017 23:22:13 +0000 (UTC)
commit e2842d057714e68017edaa79ad9b82cfd76e27ab
Author: Tim Janik <timj gnu org>
Date: Fri Feb 17 20:55:24 2017 +0100
V8BSE: V8Stub.py: add skeleton for language binding generation
Signed-off-by: Tim Janik <timj gnu org>
ebeast/v8bse/V8Stub.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/ebeast/v8bse/V8Stub.py b/ebeast/v8bse/V8Stub.py
new file mode 100644
index 0000000..505a2a1
--- /dev/null
+++ b/ebeast/v8bse/V8Stub.py
@@ -0,0 +1,47 @@
+# This Source Code Form is licensed MPL-2.0: http://mozilla.org/MPL/2.0
+"""AidaPyxxStub - Aida Cython Code Generator
+
+More details at http://www.rapicorn.org/
+"""
+import Decls, re, sys, os
+
+class Generator:
+ def __init__ (self, idl_file, module_name):
+ assert isinstance (module_name, str)
+ self.ntab = 26
+ self.idl_file = idl_file
+ self.module_name = module_name
+ self.strip_path = ""
+ self.idcounter = 1001
+ self.marshallers = {}
+ def generate_types_v8 (self, implementation_types):
+ s = '// === Generated by V8Stub.py === -*-mode:javascript;-*-\n'
+ return s
+
+def generate (namespace_list, **args):
+ import sys, tempfile, os
+ config = {}
+ config.update (args)
+ if '--print-include-path' in config.get ('backend-options', []):
+ includestem = os.path.dirname (os.path.dirname (os.path.abspath (__file__)))
+ includepath = os.path.join (includestem, 'v8')
+ print includepath
+ else:
+ outname = config.get ('output', 'testmodule')
+ if outname == '-':
+ raise RuntimeError ("-: stdout is not support for generation of multiple files")
+ idlfiles = config['files']
+ if len (idlfiles) != 1:
+ raise RuntimeError ("V8Stub: exactly one IDL input file is required")
+ gg = Generator (idlfiles[0], outname)
+ for opt in config['backend-options']:
+ if opt.startswith ('strip-path='):
+ gg.strip_path += opt[11:]
+ fname = outname
+ fout = open (fname, 'w')
+ textstring = gg.generate_types_v8 (config['implementation_types'])
+ fout.write (textstring)
+ fout.close()
+
+# register extension hooks
+__Aida__.add_backend (__file__, generate, __doc__)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]