Changeset bb16420 in tol


Ignore:
Timestamp:
Dec 11, 2010, 7:23:11 PM (16 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
96b1982
Parents:
efb66ad
Message:

New function Cint.export_to_tol

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@2787 be4846ae-f051-483a-831f-b64e7d08527f

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol/btol/bgrammar/spfuninst.cpp

    refb66ad rbb16420  
    5151#include <tol/tol_bsymboltable.h>
    5252#include <tol/tol_bnameblock.h>
     53#include <G__ci.h>
    5354
    5455BTraceInit("spfuninst.cpp");
    … …  
    17911792}
    17921793
     1794
     1795//--------------------------------------------------------------------
     1796static BSyntaxObject* EvCint_export_to_tol(BGrammar* gra, const List* tre, BBool left)
     1797
     1798/*! Evaluate Case expressions
     1799 */
     1800//--------------------------------------------------------------------
     1801{
     1802  static BText _name_ = "Cint.export_to_tol";
     1803  BInt nb = BSpecialFunction::NumBranches(tre);
     1804  BSyntaxObject* result = NULL;
     1805  if(BSpecialFunction::TestNumArg(_name_, 1, nb, 1))
     1806  {
     1807    bool oldUseModule = BOis::RunningUseModule();
     1808    BSyntaxObject* uNam = GraText()->EvaluateTree(Branch(tre,1));
     1809    if(uNam && (uNam->Grammar()==GraText()))
     1810    {
     1811      const BText& name = Text(uNam);
     1812      int ptr = 0;
     1813      G__value g;
     1814      if(gra==GraReal())
     1815      {
     1816        g = G__calc(BText("(int)(double*)(")+name+")");
     1817        if(g.type == 105 ) { ptr = g.obj.i; }
     1818        if(ptr)
     1819        {
     1820          double cnt = *(double*)ptr;
     1821          result = new BContensDat(name,cnt,"");
     1822        }
     1823      }
     1824      else if(gra==GraMatrix())
     1825      {
     1826        int rows = -1, columns = -1;
     1827        double* buffer = NULL;
     1828        g = G__calc(name+".rows_");
     1829        if(g.type == 105 ) { rows = g.obj.i; }
     1830        g = G__calc(name+".columns_");
     1831        if(g.type == 105 ) { columns = g.obj.i; }
     1832        g = G__calc(BText("(int)(double*)(")+name+".buffer_)");
     1833        if(g.type == 105 ) { buffer = (double*)g.obj.i; }
     1834        if(rows>0 && columns>0 && buffer!=NULL)
     1835        {
     1836          BMat cnt(rows, columns, (BDat*)buffer); 
     1837          result = new BContensMat(name,cnt,"");
     1838        }
     1839      }
     1840      else if(gra==GraText())
     1841      {
     1842        int length = -1;
     1843        char* buffer = NULL;
     1844        g = G__calc(name+".length_");
     1845        if(g.type == 105 ) { length = g.obj.i; }
     1846        g = G__calc(BText("(int)(char*)(")+name+".buffer_)");
     1847        if(g.type == 105 ) { buffer = (char*)g.obj.i; }
     1848        if(length>0 && buffer!=NULL)
     1849        {
     1850          BText cnt(buffer, length); 
     1851          result = new BContensText(name,cnt,"");
     1852        }
     1853      }
     1854      else
     1855      {
     1856        Error(BText("[")+_name_+"] "+
     1857              I2("Not allowed TOL type ","Tipo TOL no permitido ")+
     1858              gra->Name());
     1859      }
     1860    }
     1861    result=BSpecialFunction::TestResult(_name_,result,tre,NIL,BFALSE);
     1862  }
     1863  return(result);
     1864}
     1865
    17931866//--------------------------------------------------------------------
    17941867static bool BSpecialFunction_IsInitialized()
    … …  
    22592332     EvAvoidErrNonDecAct);
    22602333
     2334  AddInstance("Cint.export_to_tol",
     2335     "(Text name)",
     2336  I2(".",
     2337     "."),
     2338     EvCint_export_to_tol);
     2339
    22612340
    22622341  return(true);
Note: See TracChangeset for help on using the changeset viewer.