|
4 |
import os.path |
4 |
import os.path |
5 |
|
5 |
|
6 |
import pybindgen.settings |
6 |
import pybindgen.settings |
7 |
from pybindgen.gccxmlparser import ModuleParser, PygenClassifier, PygenSection, WrapperWarning, find_declaration_from_name |
7 |
from pybindgen.castxmlparser import ModuleParser, PygenClassifier, PygenSection, WrapperWarning, find_declaration_from_name |
8 |
from pybindgen.typehandlers.codesink import FileCodeSink |
8 |
from pybindgen.typehandlers.codesink import FileCodeSink |
9 |
from pygccxml.declarations import templates |
9 |
from pygccxml.declarations import templates |
10 |
from pygccxml.declarations.enumeration import enumeration_t |
10 |
from pygccxml.declarations.enumeration import enumeration_t |
11 |
from pygccxml.declarations.class_declaration import class_t |
11 |
from pygccxml.declarations.class_declaration import class_t |
12 |
from pygccxml.declarations.calldef import free_function_t, member_function_t, constructor_t, calldef_t |
12 |
from pygccxml.declarations.free_calldef import free_function_t |
13 |
|
13 |
from pygccxml.declarations.calldef_members import constructor_t, member_function_t |
|
|
14 |
from pygccxml.declarations.calldef import calldef_t |
14 |
|
15 |
|
15 |
## we need the smart pointer type transformation to be active even |
16 |
## we need the smart pointer type transformation to be active even |
16 |
## during gccxml scanning. |
17 |
## during gccxml scanning. |
|
34 |
def get_ns3_relative_path(path): |
35 |
def get_ns3_relative_path(path): |
35 |
l = [] |
36 |
l = [] |
36 |
head = path |
37 |
head = path |
|
|
38 |
if not path: |
39 |
return |
37 |
while head: |
40 |
while head: |
38 |
new_head, tail = os.path.split(head) |
41 |
new_head, tail = os.path.split(head) |
39 |
if new_head == head: |
42 |
if new_head == head: |
|
58 |
ns3_header = get_ns3_relative_path(pygccxml_definition.location.file_name) |
61 |
ns3_header = get_ns3_relative_path(pygccxml_definition.location.file_name) |
59 |
except ValueError: # the header is not from ns3 |
62 |
except ValueError: # the header is not from ns3 |
60 |
return # ignore the definition, it's not ns-3 def. |
63 |
return # ignore the definition, it's not ns-3 def. |
61 |
|
64 |
if not ns3_header: |
|
|
65 |
return |
62 |
definition_module = self.headers_map[ns3_header] |
66 |
definition_module = self.headers_map[ns3_header] |
63 |
|
67 |
|
64 |
## Note: we don't include line numbers in the comments because |
68 |
## Note: we don't include line numbers in the comments because |
|
78 |
if isinstance(pygccxml_definition, member_function_t) \ |
82 |
if isinstance(pygccxml_definition, member_function_t) \ |
79 |
and pygccxml_definition.parent.name == 'Object' \ |
83 |
and pygccxml_definition.parent.name == 'Object' \ |
80 |
and pygccxml_definition.name == 'GetObject': |
84 |
and pygccxml_definition.name == 'GetObject': |
81 |
template_args = templates.args(pygccxml_definition.demangled_name) |
85 |
print ("************************", pygccxml_definition.name) |
|
|
86 |
print ("************************", str(pygccxml_definition)) |
87 |
template_args = templates.args(str(pygccxml_definition)) |
82 |
if template_args == ['ns3::Object']: |
88 |
if template_args == ['ns3::Object']: |
83 |
global_annotations['template_instance_names'] = 'ns3::Object=>GetObject' |
89 |
global_annotations['template_instance_names'] = 'ns3::Object=>GetObject' |
84 |
|
90 |
|
|
222 |
callback_classes_file.write("]\n") |
228 |
callback_classes_file.write("]\n") |
223 |
|
229 |
|
224 |
|
230 |
|
225 |
def ns3_module_scan(top_builddir, module_name, headers_map, output_file_name, cflags): |
231 |
def ns3_module_scan(top_builddir, module_name, headers_map, output_file_name, cflag): |
226 |
module_parser = ModuleParser('ns.%s' % module_name.replace('-', '_'), 'ns3') |
232 |
module_parser = ModuleParser('ns.%s' % module_name.replace('-', '_'), 'ns3') |
227 |
module_parser.add_pre_scan_hook(PreScanHook(headers_map, module_name)) |
233 |
module_parser.add_pre_scan_hook(PreScanHook(headers_map, module_name)) |
228 |
#module_parser.add_post_scan_hook(post_scan_hook) |
234 |
#module_parser.add_post_scan_hook(post_scan_hook) |
229 |
|
235 |
|
230 |
gccxml_options = dict( |
236 |
castxml_options = dict( |
231 |
include_paths=[top_builddir], |
237 |
include_paths=[top_builddir], |
232 |
define_symbols={ |
238 |
define_symbols={ |
233 |
#'NS3_ASSERT_ENABLE': None, |
239 |
#'NS3_ASSERT_ENABLE': None, |
234 |
#'NS3_LOG_ENABLE': None, |
240 |
#'NS3_LOG_ENABLE': None, |
235 |
}, |
241 |
}, |
236 |
cflags=('--gccxml-cxxflags "%s -DPYTHON_SCAN"' % cflags) |
242 |
#cflags=(' -std=c++14') |
|
|
243 |
cflags=('-std=c++11 %s' % cflag) |
237 |
) |
244 |
) |
238 |
|
245 |
|
239 |
try: |
246 |
try: |
|
257 |
None, whitelist_paths=[top_builddir], |
264 |
None, whitelist_paths=[top_builddir], |
258 |
#includes=['"ns3/everything.h"'], |
265 |
#includes=['"ns3/everything.h"'], |
259 |
pygen_sink=output_sink, |
266 |
pygen_sink=output_sink, |
260 |
gccxml_options=gccxml_options) |
267 |
castxml_options=castxml_options) |
261 |
module_parser.scan_types() |
268 |
module_parser.scan_types() |
262 |
|
269 |
|
263 |
callback_classes_file = open(os.path.join(os.path.dirname(output_file_name), "callbacks_list.py"), "wt") |
270 |
callback_classes_file = open(os.path.join(os.path.dirname(output_file_name), "callbacks_list.py"), "wt") |