@@ -119,7 +119,6 @@ class SScript
119119
120120 **MINI** contains only basic classes like `Math`.
121121
122-
123122 **REGULAR** contains most cross-target Haxe classes.
124123
125124 **FULL** contains all existing classes.
@@ -202,9 +201,11 @@ class SScript
202201 public var notAllowedClasses (default , null ): Array <Class <Dynamic >> = [];
203202
204203 /**
205- Preset tool for this script.
204+ Preset mode of this script.
205+
206+ @see SScript.defaultPreset
206207 **/
207- public var presetter (default , null ) : Preset ;
208+ public var presetMode (default , set ) : PresetMode ;
208209
209210 /**
210211 Use this to access to interpreter's variables!
@@ -294,7 +295,7 @@ class SScript
294295
295296 parser = new Parser ();
296297
297- presetter = new Preset ( this ) ;
298+ presetMode = defaultPreset ;
298299 if (preset )
299300 this .preset ();
300301
@@ -419,9 +420,11 @@ class SScript
419420 This is a helper function for setting classes easily.
420421 For example, if `cl` is the `sys.io.File` class, it will be set as `File`.
421422 @param cl The class to set.
423+ @param setAsFinal Whether to set the object as final. If set as final,
424+ the object will act as a final variable and cannot be changed in the script.
422425 @return this instance for chaining.
423426 **/
424- public function setClass (cl : Class <Dynamic >): SScript
427+ public function setClass (cl : Class <Dynamic >, ? setAsFinal : Bool = false ): SScript
425428 {
426429 if (_destroyed )
427430 return null ;
@@ -445,7 +448,7 @@ class SScript
445448 clName = splitCl [splitCl .length - 1 ];
446449 }
447450
448- set (clName , cl );
451+ set (clName , cl , setAsFinal );
449452 }
450453 return this ;
451454 }
@@ -454,9 +457,11 @@ class SScript
454457 Sets a class in this script from a string.
455458 `cl` will be formatted. For example: `sys.io.File` -> `File`.
456459 @param cl The class to set.
460+ @param setAsFinal Whether to set the object as final. If set as final,
461+ the object will act as a final variable and cannot be changed in the script.
457462 @return this instance for chaining.
458463 **/
459- public function setClassString (cl : String ): SScript
464+ public function setClassString (cl : String , ? setAsFinal : Bool = false ): SScript
460465 {
461466 if (_destroyed )
462467 return null ;
@@ -476,7 +481,7 @@ class SScript
476481 if (parts .length > 1 )
477482 cl = parts [parts .length - 1 ];
478483
479- set (cl , cls );
484+ set (cl , cls , setAsFinal );
480485 }
481486 return this ;
482487 }
@@ -788,7 +793,7 @@ class SScript
788793 if (! active )
789794 return ;
790795
791- presetter .preset ();
796+ Preset .preset (this );
792797 }
793798
794799 function resetInterp (): Void
@@ -807,6 +812,7 @@ class SScript
807812 return ;
808813
809814 interp .specialObject = null ;
815+ interp .usingMethods = null ;
810816 interp .script = null ;
811817 interp .locals = null ;
812818 interp .variables = null ;
@@ -1032,8 +1038,6 @@ class SScript
10321038 if (ID != null && global .exists (Std .string (ID )))
10331039 global .remove (Std .string (ID ));
10341040
1035- presetter .destroy ();
1036-
10371041 removeSpecialObject ();
10381042 clear ();
10391043 resetInterp ();
@@ -1110,4 +1114,10 @@ class SScript
11101114
11111115 return defaultPreset = value ;
11121116 }
1117+
1118+ function set_presetMode (value : PresetMode ): PresetMode {
1119+ if (_destroyed )
1120+ return null ;
1121+ return presetMode = value ;
1122+ }
11131123}
0 commit comments