diff inst/private/generate_mf_constructor.m @ 261:f22588ae37af

Improve template meshfunction implementation * inst/import_meshfunction_type.m: provide to the auxiliary functions a type name and a valid identifier * inst/private/generate_mf_*.m: add space before closing angle bracket to avoid parse errors
author Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
date Thu, 07 Aug 2014 11:13:54 +0200
parents 1e2a9be8083a
children 41b76530fe5e
line wrap: on
line diff
--- a/inst/private/generate_mf_constructor.m	Wed Aug 06 19:52:03 2014 +0200
+++ b/inst/private/generate_mf_constructor.m	Thu Aug 07 11:13:54 2014 +0200
@@ -18,15 +18,15 @@
 ## function for internal usage only
 ## @end deftypefn
 
-function output = generate_mf_constructor (typename)
+function output = generate_mf_constructor (label)
 
 STRING ="\n\
 #include <dolfin.h>\n\
 #include <fem-fenics/mesh.h>\n\
-#include ""meshfunction_@@TYPENAME@@.h""\n\
+#include ""meshfunction_@@LABEL@@.h""\n\
 #include <fem-fenics/dolfin_compat.h>\n\
 \n\
-DEFUN_DLD (MeshFunction_@@TYPENAME@@, args, nargout, ""MF = MeshFunction_@@TYPENAME@@ (MESH, FILENAME)"")\n\
+DEFUN_DLD (MeshFunction_@@LABEL@@, args, nargout, ""MF = MeshFunction_@@LABEL@@ (MESH, FILENAME)"")\n\
 {\n\
 \n\
   int nargin = args.length ();\n\
@@ -43,10 +43,10 @@
           mlock ();\n\
         }\n\
 \n\
-      if (! meshfunction_@@TYPENAME@@_type_loaded)\n\
+      if (! meshfunction_@@LABEL@@_type_loaded)\n\
         {\n\
-          meshfunction_@@TYPENAME@@::register_type ();\n\
-          meshfunction_@@TYPENAME@@_type_loaded = true;\n\
+          meshfunction_@@LABEL@@::register_type ();\n\
+          meshfunction_@@LABEL@@_type_loaded = true;\n\
           mlock ();\n\
         }\n\
 \n\
@@ -64,7 +64,7 @@
               filename += "".xdmf"";\n\
 \n\
               try\n\
-                { retval = new meshfunction_@@TYPENAME@@ (pmsh, filename); }\n\
+                { retval = new meshfunction_@@LABEL@@ (pmsh, filename); }\n\
               catch (std::runtime_error &)\n\
                 { error (""error reading file""); }\n\
             }\n\
@@ -76,9 +76,9 @@
   return retval;\n\
 }";
 
-STRING =  strrep (STRING, "@@TYPENAME@@", typename);
+STRING = strrep (STRING, "@@LABEL@@", label);
 
-fid = fopen (["MeshFunction_", typename, ".cc"], "w");
+fid = fopen (["MeshFunction_", label, ".cc"], "w");
 if (is_valid_file_id (fid))
   fputs (fid, STRING);
   output = fclose (fid);