X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/10ceac5fd14fb0426b5c93bda85676a79b02d0be..aa4c04bd2a0667f488d1faf93e090756f7f98383:/src/simix/simcalls.py diff --git a/src/simix/simcalls.py b/src/simix/simcalls.py index eff39b7a07..4465a6420c 100755 --- a/src/simix/simcalls.py +++ b/src/simix/simcalls.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# Copyright (c) 2014-2016. The SimGrid Team. All rights reserved. +# Copyright (c) 2014-2017. The SimGrid Team. All rights reserved. # This program is free software; you can redistribute it and/or modify it # under the terms of the license (GNU LGPL) which comes with this package. @@ -11,9 +11,9 @@ import glob class Arg(object): - def __init__(self, name, type): + def __init__(self, name, thetype): self.name = name - self.type = type + self.type = thetype def field(self): return self.simcall_types[self.type] @@ -51,7 +51,7 @@ class Simcall(object): # smx_host_t h) if self.simcalls_PRE is None: self.simcalls_PRE = set() - for fn in glob.glob('smx_*') + glob.glob('ActorImpl*') + glob.glob('../mc/*'): + for fn in glob.glob('smx_*') + glob.glob('ActorImpl*') + glob.glob('../mc/*cpp'): f = open(fn) self.simcalls_PRE |= set(re.findall(r'simcall_HANDLER_(.*?)\(', f.read())) f.close() @@ -75,30 +75,45 @@ class Simcall(object): return ' SIMCALL_%s,' % (self.name.upper()) def string(self): - return ' "SIMCALL_%s",' % self.name.upper() + return ' "SIMCALL_%s",' % self.name.upper() def accessors(self): res = [] res.append('') + regex = re.compile(r"^boost::intrusive_ptr<(.*?)>(.*)$") # to compute the raw type # Arguments getter/setters for i in range(len(self.args)): arg = self.args[i] - res.append('static inline %s simcall_%s__get__%s(smx_simcall_t simcall) {' % ( + rawtype = regex.sub(r'\1*\2', arg.rettype()) + res.append('static inline %s simcall_%s__get__%s(smx_simcall_t simcall)' % ( arg.rettype(), self.name, arg.name)) - res.append( - ' return simgrid::simix::unmarshal<%s>(simcall->args[%i]);' % (arg.rettype(), i)) + res.append('{') + res.append(' return simgrid::simix::unmarshal<%s>(simcall->args[%i]);' % (arg.rettype(), i)) + res.append('}') + res.append('static inline %s simcall_%s__getraw__%s(smx_simcall_t simcall)' % ( + rawtype, self.name, arg.name)) + res.append('{') + res.append(' return simgrid::simix::unmarshal_raw<%s>(simcall->args[%i]);' % (rawtype, i)) res.append('}') - res.append('static inline void simcall_%s__set__%s(smx_simcall_t simcall, %s arg) {' % ( + res.append('static inline void simcall_%s__set__%s(smx_simcall_t simcall, %s arg)' % ( self.name, arg.name, arg.rettype())) + res.append('{') res.append(' simgrid::simix::marshal<%s>(simcall->args[%i], arg);' % (arg.rettype(), i)) res.append('}') # Return value getter/setters if self.res.type != 'void': + rawtype = regex.sub(r'\1*\2', self.res.rettype()) res.append( - 'static inline %s simcall_%s__get__result(smx_simcall_t simcall){' % (self.res.rettype(), self.name)) + 'static inline %s simcall_%s__get__result(smx_simcall_t simcall)' % (self.res.rettype(), self.name)) + res.append('{') + res.append(' return simgrid::simix::unmarshal<%s>(simcall->result);' % self.res.rettype()) res.append('}') + res.append( + 'static inline %s simcall_%s__getraw__result(smx_simcall_t simcall){' % (rawtype, self.name)) + res.append(' return simgrid::simix::unmarshal_raw<%s>(simcall->result);' % rawtype) + res.append('}') res.append( 'static inline void simcall_%s__set__result(smx_simcall_t simcall, %s result){' % (self.name, self.res.rettype())) res.append(' simgrid::simix::marshal<%s>(simcall->result, result);' % (self.res.rettype())) @@ -127,7 +142,7 @@ class Simcall(object): return '\n'.join(res) def body(self): - res = [' '] + res = [''] res.append( 'inline static %s simcall_BODY_%s(%s) {' % (self.res.rettype(), self.name, @@ -218,6 +233,8 @@ def header(name): '/* */\n') fd.write( '/* change simcalls specification in src/simix/simcalls.in */\n') + fd.write( + '/* Copyright (c) 2014-2017. The SimGrid Team. All rights reserved. */\n') fd.write( '/**********************************************************************/\n\n') fd.write('/*\n') @@ -233,17 +250,16 @@ def header(name): def handle(fd, func, simcalls, guarded_simcalls): - def nonempty(e): return e != '' - fd.write( - '\n'.join(filter(nonempty, (func(simcall) for simcall in simcalls)))) + def nonempty(e): + return e != '' + fd.write('\n'.join(filter(nonempty, (func(simcall) for simcall in simcalls)))) - for guard, list in guarded_simcalls.items(): + for guard, ll in guarded_simcalls.items(): fd.write('\n#if %s\n' % (guard)) - fd.write('\n'.join(func(simcall) for simcall in list)) + fd.write('\n'.join(func(simcall) for simcall in ll)) fd.write('\n#endif\n') if __name__ == '__main__': - import sys simcalls, simcalls_dict = parse('simcalls.in') ok = True @@ -290,7 +306,7 @@ if __name__ == '__main__': fd.write('#include \n') fd.write('#include "smx_private.h"\n') - fd.write('#if HAVE_MC\n') + fd.write('#if SIMGRID_HAVE_MC\n') fd.write('#include "src/mc/mc_forward.hpp"\n') fd.write('#endif\n') fd.write('\n') @@ -300,10 +316,10 @@ if __name__ == '__main__': '/** @brief Simcalls\' names (generated from src/simix/simcalls.in) */\n') fd.write('const char* simcall_names[] = {\n') - fd.write(' "SIMCALL_NONE",') + fd.write(' "SIMCALL_NONE",\n') handle(fd, Simcall.string, simcalls, simcalls_dict) - fd.write('};\n\n') + fd.write('\n};\n\n') fd.write('/** @private\n') fd.write(