Exemple #1
0
 def modify_fct(self,tryonly='tryonly') :
     """ text is always modified from old one"""
     style = self.get_tb_style()
     fct_name = self.get_fct_name()
     print("modifying fct for %s with style %s"% (fct_name,style))
     new =  self.get_fct_impl_path('scalar')
     old = new+'.old'
     if self.manual(new) :
         print("file \n   %s\nwas manually modified: skipping" % new)
         return
     if not exist(old) : self.duplicate_fct()
     oldtxt = read(old)
     (beg,end)=Nt2_fct_internals.get_header_indices(oldtxt)
     newtxt=oldtxt[beg:end]
     newtxt += Nt2_fct_internals.get_extern_C(oldtxt)
     calls = Nt2_fct_internals.get_calls(oldtxt)
     for c in calls.keys() :
         newtxt += [l.expandtabs(6) for l in self.mk_nw_call(c,calls[c])]
     newtxt += ["","#endif"]               
     newtxt += ['// modified by %s the %s' % (self.get_author(), datetime.now().strftime("%d/%m/%Y"))]
     newtxt = self.replacements(newtxt,'\sNT2_CALL_RETURN_TYPE\(',' NT2_RETURN_TYPE(')
     newtxt = self.replacements(newtxt,'long double_','long_double_')
     newtxt = self.replace('(?i)gsl_specfun::',fct_name,fct_name.lower(),newtxt)
     if tryonly != 'tryonly' :
         write(new,newtxt,False)
     else :
         print("---------------")
         PrettyPrinter().pprint(oldtxt)
         print("===============")
         PrettyPrinter().pprint(newtxt)
         print("===============")
Exemple #2
0
 def __get_striped_returns(self,txt, typ='.*') :
     d1 = Nt2_fct_internals.get_returns(txt,typ)
     d = {}
     for t in d1.keys() :
         r =  ' '.join(d1[t])
         m = re.match(".*struct result<.*?: *(.*){",r)
         if m :
             tmp = re.sub("A\d",'T',m.group(1))+'::type'
             tmp = re.sub(' ','',tmp)
             tmp = re.sub('meta','nt2::meta',tmp)
             d[t] = 'typename '+tmp
         else :
             d[t]= 'T'
     return d
Exemple #3
0
 def __get_striped_returns(self,txt, typ='.*') :
     d1 = Nt2_fct_internals.get_returns(txt,typ)
     d = {}
     for t in d1.keys() :
         r =  ' '.join(d1[t])
         m = re.match(".*struct result<.*?: *(.*){",r)
         if m :
             tmp = re.sub("A\d",'T',m.group(1))+'::type'
             tmp = re.sub(' ','',tmp)
             tmp = re.sub('meta','nt2::meta',tmp)
             d[t] = 'typename '+tmp
         else :
             d[t]= 'T'
     return d
Exemple #4
0
 def mk_fct_doc_tpl(self,
                    doc_tpl=None,
                    doc_functor=None,
                    doc_global_header=None,
                    doc_specific_values=None,
                    doc_verif_test=None,
                    arity = '1') :
     n = 4
     if doc_tpl             is None : doc_tpl = Nt2_fct_doc.Doc_tpl
     if doc_functor         is None : doc_functor = (' '*n)+Nt2_fct_doc.Doc_functor.replace('\n', '\n'+' '*n)
     if doc_global_header   is None : doc_global_header = (' '*n)+Nt2_fct_doc.Doc_global_header.replace('\n', '\n'+' '*n)
     if doc_specific_values is None :
         doc_specific_values = self.__specif_vals(Nt2_fct_internals.get_returns(self.get_fct_text()).keys(),n,arity)
     if doc_verif_test      is None : doc_verif_test = (' '*n)+Nt2_fct_doc.Doc_verif_test.replace('\n', '\n'+' '*n)
     s = doc_tpl
     s = re.sub('\$functor\$', doc_functor,s)
     s = re.sub('\$global_header\$', doc_global_header,s)
     s = re.sub('\$specific_values\$', doc_specific_values,s)
     s = re.sub('\$verif_test\$', doc_verif_test,s)
     return s
Exemple #5
0
 def get_fct_types(self) :
     return Nt2_fct_internals.get_calls(self.get_fct_text()).keys()
Exemple #6
0
 def get_fct_types(self) :
     return Nt2_fct_internals.get_calls(self.get_fct_text()).keys()