2014-07-26 18:37:20 +02:00
|
|
|
<%
|
|
|
|
import re
|
|
|
|
def deduce_normalized_python_class_name(s) :
|
|
|
|
return ''.join([x.capitalize() for x in s.split('_')])
|
Draft libclang based python wrapper desc generator
- Given a C++ file, e.g. a class,
it calls libclang to parse the C++, and retrieve from
its AST the necessary info to write a xxx_desc.py file.
- THIS IS WORK IN PROGRESS. There are several corner cases for which we
may want (or not) the script to do better.
- It is not designed to be used automatically, but to to 90 % of the
boring typesetting work...
- The preamble still needs manual choices
- The properties, methods, functions are automatically declared in
the _desc file, in the simplest possible way.
- An option --properties, -p : to transform some simple methods or
get_x, set_x into python properties, not methods.
Cf doc.
- requires clang (tested on 3.4).
- the script is configured by cmake and installed in
INSTALLATION_DIRECTORY/bin, with some other files.
It can only be used for applications, after the lib has been installed.
It is cmake configured, to include automatically the various include
paths configure in the triqs installation, including the triqs install dir
in order to simplify invocation.
- TODO : improve, and test more in real cases.
2014-07-06 23:08:33 +02:00
|
|
|
|
2014-07-26 18:37:20 +02:00
|
|
|
def decay(s) :
|
2014-09-20 22:13:14 +02:00
|
|
|
for tok in ['const ', 'const&', '&&', '&'] :
|
2014-07-26 18:37:20 +02:00
|
|
|
s = re.sub(tok,'',s)
|
2014-09-20 22:13:14 +02:00
|
|
|
s = s.replace('const_view', 'view') # DISCUSS THIS
|
2014-07-26 18:37:20 +02:00
|
|
|
return s.strip()
|
Draft libclang based python wrapper desc generator
- Given a C++ file, e.g. a class,
it calls libclang to parse the C++, and retrieve from
its AST the necessary info to write a xxx_desc.py file.
- THIS IS WORK IN PROGRESS. There are several corner cases for which we
may want (or not) the script to do better.
- It is not designed to be used automatically, but to to 90 % of the
boring typesetting work...
- The preamble still needs manual choices
- The properties, methods, functions are automatically declared in
the _desc file, in the simplest possible way.
- An option --properties, -p : to transform some simple methods or
get_x, set_x into python properties, not methods.
Cf doc.
- requires clang (tested on 3.4).
- the script is configured by cmake and installed in
INSTALLATION_DIRECTORY/bin, with some other files.
It can only be used for applications, after the lib has been installed.
It is cmake configured, to include automatically the various include
paths configure in the triqs installation, including the triqs install dir
in order to simplify invocation.
- TODO : improve, and test more in real cases.
2014-07-06 23:08:33 +02:00
|
|
|
|
2014-07-26 18:37:20 +02:00
|
|
|
# compute used_module_list
|
|
|
|
recognized_namespace_for_using = {
|
|
|
|
'triqs::gfs::' : 'gf',
|
|
|
|
'triqs::params::' : 'parameters',
|
|
|
|
'triqs::utility::many_body_operator' : 'operators2',
|
|
|
|
}
|
Draft libclang based python wrapper desc generator
- Given a C++ file, e.g. a class,
it calls libclang to parse the C++, and retrieve from
its AST the necessary info to write a xxx_desc.py file.
- THIS IS WORK IN PROGRESS. There are several corner cases for which we
may want (or not) the script to do better.
- It is not designed to be used automatically, but to to 90 % of the
boring typesetting work...
- The preamble still needs manual choices
- The properties, methods, functions are automatically declared in
the _desc file, in the simplest possible way.
- An option --properties, -p : to transform some simple methods or
get_x, set_x into python properties, not methods.
Cf doc.
- requires clang (tested on 3.4).
- the script is configured by cmake and installed in
INSTALLATION_DIRECTORY/bin, with some other files.
It can only be used for applications, after the lib has been installed.
It is cmake configured, to include automatically the various include
paths configure in the triqs installation, including the triqs install dir
in order to simplify invocation.
- TODO : improve, and test more in real cases.
2014-07-06 23:08:33 +02:00
|
|
|
|
2014-09-20 22:13:14 +02:00
|
|
|
using_needed_for_modules = {
|
|
|
|
'gf' : 'namespace triqs::gfs',
|
|
|
|
'parameters' : 'namespace triqs::params',
|
|
|
|
'operators2' : 'triqs::utility::many_body_operator',
|
|
|
|
}
|
|
|
|
|
2014-07-26 18:37:20 +02:00
|
|
|
used_module_list = []
|
|
|
|
def analyse(t) :
|
2014-09-20 22:13:14 +02:00
|
|
|
if t is None :return
|
2014-07-26 18:37:20 +02:00
|
|
|
#global used_module_list
|
|
|
|
for ns, mod in recognized_namespace_for_using.items() :
|
|
|
|
if decay(t.canonical_name).startswith(ns) :
|
2014-09-20 22:13:14 +02:00
|
|
|
used_module_list.append(mod)
|
Draft libclang based python wrapper desc generator
- Given a C++ file, e.g. a class,
it calls libclang to parse the C++, and retrieve from
its AST the necessary info to write a xxx_desc.py file.
- THIS IS WORK IN PROGRESS. There are several corner cases for which we
may want (or not) the script to do better.
- It is not designed to be used automatically, but to to 90 % of the
boring typesetting work...
- The preamble still needs manual choices
- The properties, methods, functions are automatically declared in
the _desc file, in the simplest possible way.
- An option --properties, -p : to transform some simple methods or
get_x, set_x into python properties, not methods.
Cf doc.
- requires clang (tested on 3.4).
- the script is configured by cmake and installed in
INSTALLATION_DIRECTORY/bin, with some other files.
It can only be used for applications, after the lib has been installed.
It is cmake configured, to include automatically the various include
paths configure in the triqs installation, including the triqs install dir
in order to simplify invocation.
- TODO : improve, and test more in real cases.
2014-07-06 23:08:33 +02:00
|
|
|
|
2014-07-26 18:37:20 +02:00
|
|
|
for c in classes :
|
|
|
|
for m in c.constructors :
|
|
|
|
for t,n,d in m.params : analyse(t)
|
|
|
|
for m in c.methods :
|
|
|
|
for t,n,d in m.params : analyse(t)
|
|
|
|
analyse(m.rtype)
|
2014-07-26 21:51:40 +02:00
|
|
|
for p in c.proplist :
|
|
|
|
analyse(p.getter.rtype)
|
Draft libclang based python wrapper desc generator
- Given a C++ file, e.g. a class,
it calls libclang to parse the C++, and retrieve from
its AST the necessary info to write a xxx_desc.py file.
- THIS IS WORK IN PROGRESS. There are several corner cases for which we
may want (or not) the script to do better.
- It is not designed to be used automatically, but to to 90 % of the
boring typesetting work...
- The preamble still needs manual choices
- The properties, methods, functions are automatically declared in
the _desc file, in the simplest possible way.
- An option --properties, -p : to transform some simple methods or
get_x, set_x into python properties, not methods.
Cf doc.
- requires clang (tested on 3.4).
- the script is configured by cmake and installed in
INSTALLATION_DIRECTORY/bin, with some other files.
It can only be used for applications, after the lib has been installed.
It is cmake configured, to include automatically the various include
paths configure in the triqs installation, including the triqs install dir
in order to simplify invocation.
- TODO : improve, and test more in real cases.
2014-07-06 23:08:33 +02:00
|
|
|
|
2014-09-20 22:13:14 +02:00
|
|
|
for c in classes_of_parameters :
|
|
|
|
for m in c.members :
|
|
|
|
analyse(m.type)
|
|
|
|
|
2014-07-26 18:37:20 +02:00
|
|
|
for f in functions :
|
|
|
|
for t,n,d in f.params : analyse(t)
|
|
|
|
analyse(f.rtype)
|
Draft libclang based python wrapper desc generator
- Given a C++ file, e.g. a class,
it calls libclang to parse the C++, and retrieve from
its AST the necessary info to write a xxx_desc.py file.
- THIS IS WORK IN PROGRESS. There are several corner cases for which we
may want (or not) the script to do better.
- It is not designed to be used automatically, but to to 90 % of the
boring typesetting work...
- The preamble still needs manual choices
- The properties, methods, functions are automatically declared in
the _desc file, in the simplest possible way.
- An option --properties, -p : to transform some simple methods or
get_x, set_x into python properties, not methods.
Cf doc.
- requires clang (tested on 3.4).
- the script is configured by cmake and installed in
INSTALLATION_DIRECTORY/bin, with some other files.
It can only be used for applications, after the lib has been installed.
It is cmake configured, to include automatically the various include
paths configure in the triqs installation, including the triqs install dir
in order to simplify invocation.
- TODO : improve, and test more in real cases.
2014-07-06 23:08:33 +02:00
|
|
|
|
2014-07-26 18:37:20 +02:00
|
|
|
used_module_list = set(used_module_list) # makes unique
|
2014-09-20 22:13:14 +02:00
|
|
|
using_list = [using_needed_for_modules[m] for m in used_module_list]
|
2014-07-26 18:37:20 +02:00
|
|
|
|
|
|
|
def cls(t) :
|
|
|
|
tname = decay(t.name)
|
|
|
|
if 'gf' in used_module_list: tname = re.sub('triqs::gfs::','',tname)
|
|
|
|
if 'parameters' in used_module_list: tname = re.sub('triqs::params::','',tname)
|
2014-09-20 22:13:14 +02:00
|
|
|
tname = tname.replace(' ','')
|
2014-07-26 18:37:20 +02:00
|
|
|
return tname
|
|
|
|
|
|
|
|
def make_signature(m) :
|
|
|
|
assert not m.template_list, "template functions can not be wrapped to Python"
|
|
|
|
s = "({args})"
|
|
|
|
if not m.is_constructor :
|
|
|
|
s = cls(m.rtype) + " {name} " + s
|
2014-09-20 22:13:14 +02:00
|
|
|
args = ', '.join( ["%s %s"%(cls(t),n) + (" = %s"%d if d else "") for t,n,d in m.params]) if m.parameter_arg == None else '**%s'%cls(m.params[0][0])
|
|
|
|
s = s.format(args = args, **m.__dict__)
|
2014-07-26 18:37:20 +02:00
|
|
|
return s.strip()
|
Draft libclang based python wrapper desc generator
- Given a C++ file, e.g. a class,
it calls libclang to parse the C++, and retrieve from
its AST the necessary info to write a xxx_desc.py file.
- THIS IS WORK IN PROGRESS. There are several corner cases for which we
may want (or not) the script to do better.
- It is not designed to be used automatically, but to to 90 % of the
boring typesetting work...
- The preamble still needs manual choices
- The properties, methods, functions are automatically declared in
the _desc file, in the simplest possible way.
- An option --properties, -p : to transform some simple methods or
get_x, set_x into python properties, not methods.
Cf doc.
- requires clang (tested on 3.4).
- the script is configured by cmake and installed in
INSTALLATION_DIRECTORY/bin, with some other files.
It can only be used for applications, after the lib has been installed.
It is cmake configured, to include automatically the various include
paths configure in the triqs installation, including the triqs install dir
in order to simplify invocation.
- TODO : improve, and test more in real cases.
2014-07-06 23:08:33 +02:00
|
|
|
%>
|
2014-09-20 22:13:14 +02:00
|
|
|
# Generated automatically using the command :
|
2014-07-26 21:51:40 +02:00
|
|
|
# ${shell_command}
|
2014-07-26 18:37:20 +02:00
|
|
|
from wrap_generator import *
|
Draft libclang based python wrapper desc generator
- Given a C++ file, e.g. a class,
it calls libclang to parse the C++, and retrieve from
its AST the necessary info to write a xxx_desc.py file.
- THIS IS WORK IN PROGRESS. There are several corner cases for which we
may want (or not) the script to do better.
- It is not designed to be used automatically, but to to 90 % of the
boring typesetting work...
- The preamble still needs manual choices
- The properties, methods, functions are automatically declared in
the _desc file, in the simplest possible way.
- An option --properties, -p : to transform some simple methods or
get_x, set_x into python properties, not methods.
Cf doc.
- requires clang (tested on 3.4).
- the script is configured by cmake and installed in
INSTALLATION_DIRECTORY/bin, with some other files.
It can only be used for applications, after the lib has been installed.
It is cmake configured, to include automatically the various include
paths configure in the triqs installation, including the triqs install dir
in order to simplify invocation.
- TODO : improve, and test more in real cases.
2014-07-06 23:08:33 +02:00
|
|
|
|
2014-07-26 18:37:20 +02:00
|
|
|
# The module
|
2014-09-20 22:13:14 +02:00
|
|
|
module = module_(full_name = "${modulename}", doc = "${moduledoc}")
|
2014-07-26 18:37:20 +02:00
|
|
|
|
|
|
|
# All the triqs C++/Python modules
|
|
|
|
%for mod in used_module_list :
|
|
|
|
module.use_module('${mod}')
|
|
|
|
%endfor
|
2014-09-20 22:13:14 +02:00
|
|
|
##
|
|
|
|
## All the using
|
|
|
|
##%for ns in using_list :
|
|
|
|
##module.add_using('${ns}')
|
|
|
|
##%endfor
|
2014-07-26 18:37:20 +02:00
|
|
|
|
|
|
|
# Add here all includes beyond what is automatically included by the triqs modules
|
|
|
|
module.add_include("${args.filename}")
|
|
|
|
|
|
|
|
# Add here anything to add in the C++ code at the start, e.g. namespace using
|
|
|
|
module.add_preamble("""
|
2014-09-20 22:13:14 +02:00
|
|
|
%for ns in using_list :
|
|
|
|
using ${ns};
|
|
|
|
%endfor
|
|
|
|
%for c in classes :
|
|
|
|
%for ns in c.ns :
|
|
|
|
using namespace ${ns};
|
|
|
|
%endfor
|
|
|
|
%endfor
|
|
|
|
%if classes_of_parameters :
|
|
|
|
#include "./converters.hxx"
|
|
|
|
%endif
|
2014-07-26 18:37:20 +02:00
|
|
|
""")
|
|
|
|
##
|
|
|
|
%for c in classes :
|
2014-09-20 22:13:14 +02:00
|
|
|
<%
|
|
|
|
def doc_format(member_list) :
|
|
|
|
h= ['Parameter Name', 'Type', 'Default', 'Documentation']
|
|
|
|
n_lmax = max(len(h[0]), max(len(m.name) for m in member_list))
|
|
|
|
type_lmax = max(len(h[1]), max(len(m.ctype) for m in member_list))
|
|
|
|
opt_lmax = max(len(h[2]), max(len(m.initializer) for m in member_list if m.initializer))
|
|
|
|
doc_lmax = max(len(h[3]), max(len(m.doc) for m in member_list))
|
|
|
|
form = " {:<%s} {:<%s} {:<%s} {:<%s}"%(n_lmax, type_lmax, opt_lmax, doc_lmax)
|
|
|
|
header = form.format(*h)
|
|
|
|
r = '\n'.join( form.format(m.name, m.ctype, m.initializer if m.initializer else '--', m.doc) for m in member_list)
|
|
|
|
return header + '\n\n' + r
|
|
|
|
%>
|
2014-07-26 18:37:20 +02:00
|
|
|
# The class ${c.name}
|
2014-09-20 22:13:14 +02:00
|
|
|
c = class_(
|
Draft libclang based python wrapper desc generator
- Given a C++ file, e.g. a class,
it calls libclang to parse the C++, and retrieve from
its AST the necessary info to write a xxx_desc.py file.
- THIS IS WORK IN PROGRESS. There are several corner cases for which we
may want (or not) the script to do better.
- It is not designed to be used automatically, but to to 90 % of the
boring typesetting work...
- The preamble still needs manual choices
- The properties, methods, functions are automatically declared in
the _desc file, in the simplest possible way.
- An option --properties, -p : to transform some simple methods or
get_x, set_x into python properties, not methods.
Cf doc.
- requires clang (tested on 3.4).
- the script is configured by cmake and installed in
INSTALLATION_DIRECTORY/bin, with some other files.
It can only be used for applications, after the lib has been installed.
It is cmake configured, to include automatically the various include
paths configure in the triqs installation, including the triqs install dir
in order to simplify invocation.
- TODO : improve, and test more in real cases.
2014-07-06 23:08:33 +02:00
|
|
|
py_type = "${deduce_normalized_python_class_name(c.name)}", # name of the python class
|
|
|
|
c_type = "${c.name}", # name of the C++ class
|
2014-09-20 22:13:14 +02:00
|
|
|
%if 0 :
|
Draft libclang based python wrapper desc generator
- Given a C++ file, e.g. a class,
it calls libclang to parse the C++, and retrieve from
its AST the necessary info to write a xxx_desc.py file.
- THIS IS WORK IN PROGRESS. There are several corner cases for which we
may want (or not) the script to do better.
- It is not designed to be used automatically, but to to 90 % of the
boring typesetting work...
- The preamble still needs manual choices
- The properties, methods, functions are automatically declared in
the _desc file, in the simplest possible way.
- An option --properties, -p : to transform some simple methods or
get_x, set_x into python properties, not methods.
Cf doc.
- requires clang (tested on 3.4).
- the script is configured by cmake and installed in
INSTALLATION_DIRECTORY/bin, with some other files.
It can only be used for applications, after the lib has been installed.
It is cmake configured, to include automatically the various include
paths configure in the triqs installation, including the triqs install dir
in order to simplify invocation.
- TODO : improve, and test more in real cases.
2014-07-06 23:08:33 +02:00
|
|
|
#
|
2014-07-26 18:37:20 +02:00
|
|
|
#Hereafter several options to be selected by hand. Cf doc
|
Draft libclang based python wrapper desc generator
- Given a C++ file, e.g. a class,
it calls libclang to parse the C++, and retrieve from
its AST the necessary info to write a xxx_desc.py file.
- THIS IS WORK IN PROGRESS. There are several corner cases for which we
may want (or not) the script to do better.
- It is not designed to be used automatically, but to to 90 % of the
boring typesetting work...
- The preamble still needs manual choices
- The properties, methods, functions are automatically declared in
the _desc file, in the simplest possible way.
- An option --properties, -p : to transform some simple methods or
get_x, set_x into python properties, not methods.
Cf doc.
- requires clang (tested on 3.4).
- the script is configured by cmake and installed in
INSTALLATION_DIRECTORY/bin, with some other files.
It can only be used for applications, after the lib has been installed.
It is cmake configured, to include automatically the various include
paths configure in the triqs installation, including the triqs install dir
in order to simplify invocation.
- TODO : improve, and test more in real cases.
2014-07-06 23:08:33 +02:00
|
|
|
#has_iterator = True,
|
|
|
|
#boost_serializable= True,
|
|
|
|
#is_printable= True,
|
|
|
|
#arithmetic = ("algebra","double")
|
2014-09-20 22:13:14 +02:00
|
|
|
%endif
|
|
|
|
)
|
Draft libclang based python wrapper desc generator
- Given a C++ file, e.g. a class,
it calls libclang to parse the C++, and retrieve from
its AST the necessary info to write a xxx_desc.py file.
- THIS IS WORK IN PROGRESS. There are several corner cases for which we
may want (or not) the script to do better.
- It is not designed to be used automatically, but to to 90 % of the
boring typesetting work...
- The preamble still needs manual choices
- The properties, methods, functions are automatically declared in
the _desc file, in the simplest possible way.
- An option --properties, -p : to transform some simple methods or
get_x, set_x into python properties, not methods.
Cf doc.
- requires clang (tested on 3.4).
- the script is configured by cmake and installed in
INSTALLATION_DIRECTORY/bin, with some other files.
It can only be used for applications, after the lib has been installed.
It is cmake configured, to include automatically the various include
paths configure in the triqs installation, including the triqs install dir
in order to simplify invocation.
- TODO : improve, and test more in real cases.
2014-07-06 23:08:33 +02:00
|
|
|
|
|
|
|
%for m in c.members :
|
2014-09-20 22:13:14 +02:00
|
|
|
c.add_member(c_name = "${m.name}",
|
Draft libclang based python wrapper desc generator
- Given a C++ file, e.g. a class,
it calls libclang to parse the C++, and retrieve from
its AST the necessary info to write a xxx_desc.py file.
- THIS IS WORK IN PROGRESS. There are several corner cases for which we
may want (or not) the script to do better.
- It is not designed to be used automatically, but to to 90 % of the
boring typesetting work...
- The preamble still needs manual choices
- The properties, methods, functions are automatically declared in
the _desc file, in the simplest possible way.
- An option --properties, -p : to transform some simple methods or
get_x, set_x into python properties, not methods.
Cf doc.
- requires clang (tested on 3.4).
- the script is configured by cmake and installed in
INSTALLATION_DIRECTORY/bin, with some other files.
It can only be used for applications, after the lib has been installed.
It is cmake configured, to include automatically the various include
paths configure in the triqs installation, including the triqs install dir
in order to simplify invocation.
- TODO : improve, and test more in real cases.
2014-07-06 23:08:33 +02:00
|
|
|
c_type = "${m.ctype}",
|
|
|
|
read_only= False,
|
|
|
|
doc = """${m.doc} """)
|
|
|
|
|
|
|
|
%endfor
|
|
|
|
##
|
|
|
|
%for m in [m for m in c.constructors if not m.is_template]:
|
2014-09-20 22:13:14 +02:00
|
|
|
c.add_constructor("""${make_signature(m)}""",
|
Draft libclang based python wrapper desc generator
- Given a C++ file, e.g. a class,
it calls libclang to parse the C++, and retrieve from
its AST the necessary info to write a xxx_desc.py file.
- THIS IS WORK IN PROGRESS. There are several corner cases for which we
may want (or not) the script to do better.
- It is not designed to be used automatically, but to to 90 % of the
boring typesetting work...
- The preamble still needs manual choices
- The properties, methods, functions are automatically declared in
the _desc file, in the simplest possible way.
- An option --properties, -p : to transform some simple methods or
get_x, set_x into python properties, not methods.
Cf doc.
- requires clang (tested on 3.4).
- the script is configured by cmake and installed in
INSTALLATION_DIRECTORY/bin, with some other files.
It can only be used for applications, after the lib has been installed.
It is cmake configured, to include automatically the various include
paths configure in the triqs installation, including the triqs install dir
in order to simplify invocation.
- TODO : improve, and test more in real cases.
2014-07-06 23:08:33 +02:00
|
|
|
doc = """${m.doc} """)
|
|
|
|
|
|
|
|
%endfor
|
|
|
|
##
|
2014-09-20 22:13:14 +02:00
|
|
|
%for m in c.methods:
|
|
|
|
c.add_method("""${make_signature(m)}""",
|
Draft libclang based python wrapper desc generator
- Given a C++ file, e.g. a class,
it calls libclang to parse the C++, and retrieve from
its AST the necessary info to write a xxx_desc.py file.
- THIS IS WORK IN PROGRESS. There are several corner cases for which we
may want (or not) the script to do better.
- It is not designed to be used automatically, but to to 90 % of the
boring typesetting work...
- The preamble still needs manual choices
- The properties, methods, functions are automatically declared in
the _desc file, in the simplest possible way.
- An option --properties, -p : to transform some simple methods or
get_x, set_x into python properties, not methods.
Cf doc.
- requires clang (tested on 3.4).
- the script is configured by cmake and installed in
INSTALLATION_DIRECTORY/bin, with some other files.
It can only be used for applications, after the lib has been installed.
It is cmake configured, to include automatically the various include
paths configure in the triqs installation, including the triqs install dir
in order to simplify invocation.
- TODO : improve, and test more in real cases.
2014-07-06 23:08:33 +02:00
|
|
|
%if m.is_static :
|
|
|
|
is_static = True,
|
|
|
|
%endif
|
2014-09-20 22:13:14 +02:00
|
|
|
doc = """${m.doc if m.parameter_arg==None else doc_format(m.parameter_arg.members) } """)
|
Draft libclang based python wrapper desc generator
- Given a C++ file, e.g. a class,
it calls libclang to parse the C++, and retrieve from
its AST the necessary info to write a xxx_desc.py file.
- THIS IS WORK IN PROGRESS. There are several corner cases for which we
may want (or not) the script to do better.
- It is not designed to be used automatically, but to to 90 % of the
boring typesetting work...
- The preamble still needs manual choices
- The properties, methods, functions are automatically declared in
the _desc file, in the simplest possible way.
- An option --properties, -p : to transform some simple methods or
get_x, set_x into python properties, not methods.
Cf doc.
- requires clang (tested on 3.4).
- the script is configured by cmake and installed in
INSTALLATION_DIRECTORY/bin, with some other files.
It can only be used for applications, after the lib has been installed.
It is cmake configured, to include automatically the various include
paths configure in the triqs installation, including the triqs install dir
in order to simplify invocation.
- TODO : improve, and test more in real cases.
2014-07-06 23:08:33 +02:00
|
|
|
|
|
|
|
%endfor
|
|
|
|
##
|
|
|
|
%for p in [p for p in c.proplist]:
|
2014-09-20 22:13:14 +02:00
|
|
|
c.add_property(name = "${p.name}",
|
Draft libclang based python wrapper desc generator
- Given a C++ file, e.g. a class,
it calls libclang to parse the C++, and retrieve from
its AST the necessary info to write a xxx_desc.py file.
- THIS IS WORK IN PROGRESS. There are several corner cases for which we
may want (or not) the script to do better.
- It is not designed to be used automatically, but to to 90 % of the
boring typesetting work...
- The preamble still needs manual choices
- The properties, methods, functions are automatically declared in
the _desc file, in the simplest possible way.
- An option --properties, -p : to transform some simple methods or
get_x, set_x into python properties, not methods.
Cf doc.
- requires clang (tested on 3.4).
- the script is configured by cmake and installed in
INSTALLATION_DIRECTORY/bin, with some other files.
It can only be used for applications, after the lib has been installed.
It is cmake configured, to include automatically the various include
paths configure in the triqs installation, including the triqs install dir
in order to simplify invocation.
- TODO : improve, and test more in real cases.
2014-07-06 23:08:33 +02:00
|
|
|
getter = cfunction("${make_signature(p.getter)}"),
|
|
|
|
%if p.setter :
|
|
|
|
setter = cfunction("${make_signature(p.setter)}"),
|
|
|
|
%endif
|
|
|
|
doc = """${p.doc} """)
|
|
|
|
|
|
|
|
%endfor
|
|
|
|
##
|
2014-09-20 22:13:14 +02:00
|
|
|
module.add_class(c)
|
Draft libclang based python wrapper desc generator
- Given a C++ file, e.g. a class,
it calls libclang to parse the C++, and retrieve from
its AST the necessary info to write a xxx_desc.py file.
- THIS IS WORK IN PROGRESS. There are several corner cases for which we
may want (or not) the script to do better.
- It is not designed to be used automatically, but to to 90 % of the
boring typesetting work...
- The preamble still needs manual choices
- The properties, methods, functions are automatically declared in
the _desc file, in the simplest possible way.
- An option --properties, -p : to transform some simple methods or
get_x, set_x into python properties, not methods.
Cf doc.
- requires clang (tested on 3.4).
- the script is configured by cmake and installed in
INSTALLATION_DIRECTORY/bin, with some other files.
It can only be used for applications, after the lib has been installed.
It is cmake configured, to include automatically the various include
paths configure in the triqs installation, including the triqs install dir
in order to simplify invocation.
- TODO : improve, and test more in real cases.
2014-07-06 23:08:33 +02:00
|
|
|
|
|
|
|
%endfor
|
|
|
|
##
|
|
|
|
%for f in functions :
|
|
|
|
module.add_function ("${make_signature(f)}", doc = "${f.doc}")
|
|
|
|
|
|
|
|
%endfor
|
|
|
|
##
|
|
|
|
module.generate_code()
|
|
|
|
|