Permalink
Browse files

AUTO_EVAL_STRINGS

  • Loading branch information...
1 parent 1883659 commit 360d7adc5f0dda763e665b1950143f0a850e0464 Valerio Bigiani committed Apr 8, 2012
Showing with 42 additions and 3 deletions.
  1. +3 −0 README-WeiDU-Changes.txt
  2. +3 −0 doc/base.tex
  3. +1 −0 src/toldparser.mly
  4. +16 −0 src/tp.ml
  5. +4 −1 src/tppe.ml
  6. +12 −1 src/tpwork.ml
  7. +3 −1 src/trealparserin.in
@@ -3,6 +3,9 @@ Versione 232:
* Fixed a stack overflow when using COPY_EXISTING_REGEXP and you have more
than ~60000 files between your override and key.
* Lowercase the file name of binaries on Linux.
+ * AUTO_EVAL_STRINGS adds an implicit EVALUATE_BUFFER in front of every patch
+ string (notably, when dealing with arrays or functions).
+ * in LAUNCH_*_FUNCTION, RET num is shorthand for RET num = ~%num%~.
Version 231:
* Fixed a bug that caused DISABLE_FROM_KEY to delete random files instead
View
@@ -2811,6 +2811,9 @@ \section{Module Packaging: \DEFINE{TP2} Files}
a single step. See the \ttref{QUICK!MENU} tutorial for synthax, usage
instructions, and caveats. \\
+ or & \DEFINE{AUTO!EVAL!STRINGS} &
+ If used, an EVALUATE_BUFFER is implied everywhere is possible. In particular,
+ you can now "forget" about using it in FUNCTIONs or arrays. \\
\\
\DEFINE{Language} & &
View
@@ -347,6 +347,7 @@ optional_evaluate :
Tp.flags = $5 ;
Tp.languages = $6 ;
Tp.module_list = $7 ;
+ Tp.is_auto_eval_string = List.mem Tp.Auto_Eval_Strings $5;
} }
;
View
@@ -46,6 +46,7 @@ type tp_flag =
| Readme of string list
| Uninstall_Order of string list
| Quick_Menu of (Dlg.tlk_string * int list) list * int list
+ | Auto_Eval_Strings
and must_get_var =
| Must_Get_Var of string
@@ -62,6 +63,7 @@ and tp_file = {
flags : tp_flag list ;
languages : tp_lang list ;
module_list : tp_mod list ;
+ is_auto_eval_string : bool;
}
and tp_lang = {
@@ -529,3 +531,17 @@ let log_name = "WeiDU.log"
let the_log : installed_mods ref = ref []
let current_exception = ref Not_found
+
+let saved_tp = ref None
+
+let the_tp () = match !saved_tp with
+| None -> {
+ tp_filename = "TP FILE NOT LOADED";
+ backup = "TP FILE NOT LOADED";
+ author = "TP FILE NOT LOADED";
+ flags = [];
+ languages = [];
+ module_list = [];
+ is_auto_eval_string = false;
+}
+| Some x -> x
View
@@ -32,7 +32,10 @@ let is_true i = i <> 0l
let if_true p = if p then 1l else 0l
let rec eval_pe_str s = match s with
-| PE_LiteralString(s) -> s
+| PE_LiteralString(s) -> (
+ match (the_tp()).is_auto_eval_string with
+ | false -> s
+ | true -> Var.get_string s)
| PE_GetVar(p) -> (try Var.get_string_exact ("%" ^ eval_pe_str p ^ "%") with _ -> eval_pe_str p)
| PE_Evaluate(p) -> Var.get_string (eval_pe_str p)
| PE_Uppercase(s) -> String.uppercase (eval_pe_str s)
View
@@ -320,7 +320,7 @@ let rec handle_tp
failwith "ERROR: QUICK_MENU and component 0 isn't defined."
end;
- let handle_letter tp answer can_uninstall temp_uninst package_name m finished i =
+ let handle_letter_inner tp answer can_uninstall temp_uninst package_name m finished i =
let subgroup_already =
match subcomp_group m with
| Some(ts) ->
@@ -590,6 +590,17 @@ let rec handle_tp
| _ -> ()
in
+ let handle_letter tp answer can_uninstall temp_uninst package_name m finished i =
+ saved_tp := Some tp;
+ try
+ let ans = handle_letter_inner tp answer can_uninstall temp_uninst package_name m finished i in
+ saved_tp := None;
+ ans
+ with e ->
+ saved_tp := None;
+ raise e
+ in
+
let specify = ref false in
let rec findgroup flags =
@@ -77,6 +77,7 @@ nonterm (Tp.tp_file) Tp_File {
Tp.flags = e3;
Tp.languages = e4 ;
Tp.module_list = e5 ;
+ Tp.is_auto_eval_string = List.mem Tp.Auto_Eval_Strings e3;
} ]
}
@@ -173,6 +174,7 @@ nonterm (Tp.tp_flag) Tp_Flag {
) e1;
Tp.Uninstall_Order (List.map String.uppercase e1) ]
-> QUICK_MENU ALWAYS_ASK e0:String_List END e1:Menu_List END [ Tp.Quick_Menu (e1,List.map int_of_string e0) ]
+ -> AUTO_EVAL_STRINGS [ Tp.Auto_Eval_Strings ]
}
nonterm((Dlg.tlk_string * int list) list) Menu_List {
@@ -602,7 +604,7 @@ nonterm((Tp.tp_pe_string * Tp.tp_pe_string) list) LaunchFunctionStrVar {
nonterm((Tp.tp_pe_string * Tp.tp_pe_string) list) LaunchFunctionRet {
-> { [] }
- -> RET e1:PeStr_PeStr_List { e1 }
+ -> RET e1:PeStr_PeStrMaybe_List { e1 }
}
nonterm((Tp.tp_pe_string * Tp.tp_pe_string) list) PeStr_PeStr_List {

0 comments on commit 360d7ad

Please sign in to comment.