summaryrefslogtreecommitdiff
path: root/lib/sbin/create_c_stuff.pl
diff options
context:
space:
mode:
authorgoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-08-26 15:34:20 +0000
committergoodale <goodale@17b73243-c579-4c4c-a9d2-2d5706c11dac>1999-08-26 15:34:20 +0000
commit5e90d4682484a0b9cbc232d0005bcda3895f6c9f (patch)
treed14c7ec57f48fd431663326f9c7b55900846aa47 /lib/sbin/create_c_stuff.pl
parent9a643dc37c6334abd06d70688d2e1494c435bbf2 (diff)
New parameter stuff.
Now a non-active thorn's extensions to parameters shouldn't be valid, range checking is now done, even for strings, which must conform to a regular expression. Tom git-svn-id: http://svn.cactuscode.org/flesh/trunk@859 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/sbin/create_c_stuff.pl')
-rw-r--r--lib/sbin/create_c_stuff.pl68
1 files changed, 63 insertions, 5 deletions
diff --git a/lib/sbin/create_c_stuff.pl b/lib/sbin/create_c_stuff.pl
index 6508146a..d986c6d9 100644
--- a/lib/sbin/create_c_stuff.pl
+++ b/lib/sbin/create_c_stuff.pl
@@ -92,6 +92,11 @@ sub CreateParameterBindingFile
push(@data, "");
+ push(@data, &create_parameter_code($structure,$parameters{$parameter},
+ $parameter, %parameter_database));
+
+ push(@data, "");
+
}
push(@data, " return 0;");
@@ -218,11 +223,6 @@ sub set_parameter_code
}
$line .= ");";
}
- elsif( $type eq "KEYWORD")
- {
- $line = " retval = CCTK_SetKeyword(\&($structure.$parameter), value);" ;
-
- }
elsif( $type eq "STRING" || $type eq "SENTENCE")
{
$line = " retval = CCTK_SetString(\&($structure.$parameter),value);" ;
@@ -576,5 +576,63 @@ sub help_parameter_code
return @lines;
}
+
+
+sub create_parameter_code
+{
+ local($structure, $implementation,$parameter, %parameter_database) = @_;
+ local($type, $type_string);
+ local($line, @lines);
+ local($default);
+ local($temp_default);
+
+ $default = $parameter_database{"\U$implementation $parameter\E default"};
+ $type = $parameter_database{"\U$implementation $parameter\E type"};
+
+ $type_string = &get_c_type_string($type);
+
+ if($type_string eq "char *")
+ {
+ $line = " $structure" .".$parameter = malloc("
+ . (length($default)-1). "\*sizeof(char));";
+ push(@lines, $line);
+
+ $line = " if($structure.$parameter)";
+ push(@lines, $line);
+
+ $line = " strcpy($structure.$parameter, $default);";
+ push(@lines, $line);
+ }
+ elsif($type eq "LOGICAL")
+ {
+ # Logicals need to be done specially.
+
+ # Strip out any quote marks, and spaces at start and end.
+ $temp_default = $default;
+ $temp_default =~ s:\"::g;
+ $temp_default =~ s:\s*$:: ;
+ $temp_default =~ s:^\s*:: ;
+
+ $line = " CCTK_SetLogical(\&($structure.$parameter),\"$temp_default\");";
+ push(@lines, $line);
+ }
+ else
+ {
+ $line = " $structure.$parameter = $default;";
+ push(@lines, $line);
+ }
+
+ $line = "ParameterCreate($parameter, $implementation,
+ \"foobar\",\"" . $parameter_database{"\U$implementation $parameter\E type"}."\"
+ const char *scope,
+ int steerable,
+ const char *description,
+ const char *defval,
+ void *data)";
+
+
+ return @lines;
+}
1;
+