aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjthorn <jthorn@df1f8a13-aa1d-4dd4-9681-27ded5b42416>2002-05-19 13:12:54 +0000
committerjthorn <jthorn@df1f8a13-aa1d-4dd4-9681-27ded5b42416>2002-05-19 13:12:54 +0000
commit13f1732c4f1ea3ea0eba489d1b8e15f6f160b218 (patch)
tree30527ed8ecbba2f0fb6577c1ecffe766a7a21989
parent5f46bf9ec04af74c2f0c3e264d1460bd5b3a133d (diff)
this function used to be in ../src/GeneralizedPolynomial-Uniform/util.maple
git-svn-id: http://svn.cactuscode.org/arrangements/CactusBase/LocalInterp/trunk@49 df1f8a13-aa1d-4dd4-9681-27ded5b42416
-rw-r--r--archive/C_str.maple42
1 files changed, 42 insertions, 0 deletions
diff --git a/archive/C_str.maple b/archive/C_str.maple
new file mode 100644
index 0000000..e0335a6
--- /dev/null
+++ b/archive/C_str.maple
@@ -0,0 +1,42 @@
+#
+# This function is a wrapper around codegen[C]() which returns the
+# genenerated code explictly as a Maple string.
+#
+# Arguments:
+# expr = (in) The expression for which code is to be generated.
+# ... = (in) Any further arguments are taken as options to be passed
+# to codegen[C]()
+#
+# Results:
+# The function returns a maple string of C code.
+#
+C_str :=
+proc(expr::algebraic)
+local tempname, str, temp;
+
+# name of temp file
+# FIXME: should use process number to ensure uniqueness
+tempname := "/tmp/C_str.tmp.c";
+
+# truncate temp file to zero length
+fopen(tempname, WRITE);
+fclose(tempname);
+
+# generate the code
+codegen[C](args, filename=tempname);
+
+# read the code back in
+str := "";
+ while true
+ do
+ temp := readline(tempname);
+ if (temp = 0)
+ then break;
+ end if;
+ str := cat(str, temp);
+ end do;
+fclose(tempname);
+
+# strip off the leading " t0 = "
+return op(2,sscanf(str, "%s = %[^;];"));
+end proc;