Skip to content
Snippets Groups Projects
Select Git revision
  • 3f147e49852e19b79b873f3f88edaff2314ae196
  • master default protected
  • hierarchical-basis
  • alphashapes
  • bl
  • relaying
  • new_export_boris
  • oras_vs_osm
  • reassign_partitions
  • distributed_fwi
  • rename-classes
  • fix/fortran-api-example-t4
  • robust_partitions
  • reducing_files
  • fix_overlaps
  • 3115-issue-fix
  • 3023-Fillet2D-Update
  • convert_fdivs
  • tmp_jcjc24
  • fixedMeshIF
  • save_edges
  • gmsh_4_14_0
  • gmsh_4_13_1
  • gmsh_4_13_0
  • gmsh_4_12_2
  • gmsh_4_12_1
  • gmsh_4_12_0
  • gmsh_4_11_1
  • gmsh_4_11_0
  • gmsh_4_10_5
  • gmsh_4_10_4
  • gmsh_4_10_3
  • gmsh_4_10_2
  • gmsh_4_10_1
  • gmsh_4_10_0
  • gmsh_4_9_5
  • gmsh_4_9_4
  • gmsh_4_9_3
  • gmsh_4_9_2
  • gmsh_4_9_1
  • gmsh_4_9_0
41 results

compute_normal_form.cpp

Blame
  • FunctionManager.cpp 1.82 KiB
    /* $Id: FunctionManager.cpp,v 1.5 2001-01-01 20:48:40 geuzaine Exp $ */
    #include <stdio.h>
    #include <stack>
    #include <map>
    #include "FunctionManager.h"
    
    struct ltstr
    {
      bool operator()(const char* s1, const char* s2) const
      {
        return strcmp(s1, s2) < 0;
      }
    };
    
    class File_Position 
    {
      public :
        int lineno;
        fpos_t position;
        FILE *file;
    };
    
    // Pour utiliser un namespace global sur SGI, il faut compiler avec
    // -LANG:std, et ajouter "use namespace std;". Dans tous les cas, il
    // FAUT creer les librairies avec 'CC -ar', et pas avec 'ar'.
    
    class mystack
    {
    public:
      //std::stack<File_Position> s;
      stack<File_Position> s;
    };
    class mymap
    {
    public :
      //std::map<char*,File_Position,ltstr> m;
      map<char*,File_Position,ltstr> m;
    };
    
    FunctionManager *FunctionManager::instance = 0;
    
    FunctionManager::FunctionManager()
    {
      functions = new mymap;
      calls = new mystack;
    }
    
    FunctionManager* FunctionManager::Instance()
    {
      if(!instance)
        {
          instance = new FunctionManager;
        }
      return instance;
    }
    
    bool FunctionManager::enterFunction(char *name, FILE **f, int &lno) const
    {
      if(functions->m.find(name) == functions->m.end())return false;
      File_Position fpold;
      fpold.lineno = lno;
      fpold.file = *f;
      fgetpos(fpold.file,&fpold.position);
      calls->s.push(fpold);
      File_Position fp = (functions->m)[name];
      fsetpos(fp.file,&fp.position);
      *f = fp.file;
      lno = fp.lineno;
      return true;
    }
    
    bool FunctionManager::leaveFunction(FILE **f,int &lno)
    {
      if(!calls->s.size())return false;
      File_Position fp;
      fp = calls->s.top();
      calls->s.pop();
      fsetpos(fp.file,&fp.position);
      *f = fp.file;
      lno = fp.lineno;
      return true;
    }
    
    bool FunctionManager::createFunction(char *name, FILE *f, int lno)
    {
      File_Position fp;
      fp.file = f;
      fp.lineno = lno;
      fgetpos(fp.file,&fp.position);
      (functions->m)[name] = fp;
      return true;
    }