@@ -44,6 +44,7 @@
flash9 : fixed use of default values when null is passed for nullable basic types
all : fixed issues with inlining and class/function type parameters
all : big speedup for compiler internal completion
+ all : added --macro keepClass('classname')
2010-08-14: 2.06
neko : change serializer to be able to handle instances of basic classes from other modules
@@ -507,7 +507,7 @@ let filter_dead_classes com =
com.types <- List.filter (fun t ->
match t with
| TClassDecl c ->
- if c.cl_extern then
+ if (c.cl_extern or has_meta ":keep" c.cl_meta) then
true
else (match (c.cl_ordered_statics, c.cl_ordered_fields, c.cl_constructor) with
| ([], [], None) ->
@@ -169,6 +169,19 @@ class Compiler {
} catch( e : haxe.io.Eof ) {
}
+
+ /**
+ Mark a class (or array of classes) with the metadata @:keep
+ **/
+ public static function keepClass(?cl : String, ?acl : Array<String>)
+ {
+ if (null == acl)
+ acl = [];
+ if (null != cl)
+ acl.push(cl);
+ for(cl in acl)
+ addMetadata("@:keep", cl);
+ }
static function load( f, nargs ) : Dynamic {
#if macro
@@ -803,7 +803,6 @@ let init_class ctx c p herits fields =
) in
cf.cf_type <- TLazy r;
(fun () ->
- if ctx.com.verbose then print_endline ("field " ^ (s_type_path c.cl_path) ^ "." ^ cf.cf_name);
if not (keep f stat) then
delay ctx (remove_var_if_unreferenced cf stat)
else