Browse Source

[cs] respect core_api_serialize : enums.

Cauê Waneck 11 years ago
parent
commit
3c951aef6c
6 changed files with 16 additions and 6 deletions
  1. 2 0
      common.ml
  2. 9 1
      gencommon.ml
  3. 1 1
      std/cs/_std/Array.hx
  4. 1 1
      std/cs/_std/Date.hx
  5. 2 2
      std/cs/internal/HxObject.hx
  6. 1 1
      std/cs/internal/Null.hx

+ 2 - 0
common.ml

@@ -168,6 +168,7 @@ module Define = struct
 		| As3
 		| CheckXmlProxy
 		| CoreApi
+		| CoreApiSerialize
 		| Cppia
 		| Dce
 		| DceDebug
@@ -242,6 +243,7 @@ module Define = struct
 		| As3 -> ("as3","Defined when outputing flash9 as3 source code")
 		| CheckXmlProxy -> ("check_xml_proxy","Check the used fields of the xml proxy")
 		| CoreApi -> ("core_api","Defined in the core api context")
+		| CoreApiSerialize -> ("core_api_serialize","Sets so some generated core api classes be marked with the Serializable attribute on C#")
 		| Cppia -> ("cppia", "Generate experimental cpp instruction assembly")
 		| Dce -> ("dce","The current DCE mode")
 		| DceDebug -> ("dce_debug","Show DCE log")

+ 9 - 1
gencommon.ml

@@ -1085,7 +1085,11 @@ let generate_modules gen extension source_dir (module_gen : SourceWriter.source_
 						with | Not_found ->
 							"."
 					in
-					base_path ^ "/" ^ gen.gcon.file
+					match List.rev (fst md_def.m_path) with
+						| "editor" :: _ ->
+							base_path ^ "/" ^ gen.gcon.file ^ "/Editor"
+						| _ ->
+							base_path ^ "/" ^ gen.gcon.file
 				else match List.rev (fst md_def.m_path) with
 					| "editor" :: _ ->
 						Common.defined_value gen.gcon Define.UnityStdTarget ^ "/Editor/" ^ (String.concat "/" (fst md_def.m_path))
@@ -8698,6 +8702,10 @@ struct
 			en.e_meta <- (Meta.Class, [], pos) :: en.e_meta;
 			cl.cl_module <- en.e_module;
 			cl.cl_meta <- ( Meta.Enum, [], pos ) :: cl.cl_meta;
+			(match gen.gcon.platform with
+				| Cs when Common.defined gen.gcon Define.CoreApiSerialize ->
+					cl.cl_meta <- ( Meta.Meta, [ (EField( (EConst (Ident "System"), null_pos ), "Serializable" ), null_pos) ], null_pos ) :: cl.cl_meta
+				| _ -> ());
 			let c_types =
 				if handle_type_params then
 					List.map (fun (s,t) -> (s, TInst (map_param (get_cl_t t), []))) en.e_types

+ 1 - 1
std/cs/_std/Array.hx

@@ -28,7 +28,7 @@ import cs.NativeArray;
 		this.length = native.Length;
 	}
 ')
-#if coreApiSerialize
+#if core_api_serialize
 @:meta(System.Serializable)
 #end
 @:final @:coreApi class Array<T> implements ArrayAccess<T> {

+ 1 - 1
std/cs/_std/Date.hx

@@ -24,7 +24,7 @@ import cs.system.DateTime;
 import cs.system.TimeSpan;
 import haxe.Int64;
 
-#if coreApiSerialize
+#if core_api_serialize
 @:meta(System.Serializable)
 #end
 @:coreApi class Date

+ 2 - 2
std/cs/internal/HxObject.hx

@@ -33,7 +33,7 @@ private interface IHxObject
 {
 }
 
-#if coreApiSerialize
+#if core_api_serialize
 @:meta(System.Serializable)
 #end
 @:keep @:native('haxe.lang.DynamicObject')
@@ -69,7 +69,7 @@ private class DynamicObject extends HxObject implements Dynamic
 
 @:native('haxe.lang.Enum')
 @:keep @:skipCtor
-#if coreApiSerialize
+#if core_api_serialize
 @:meta(System.Serializable)
 #end
 private class Enum

+ 1 - 1
std/cs/internal/Null.hx

@@ -37,7 +37,7 @@ package cs.internal;
 		}
 	}
 ')
-#if coreApiSerialize
+#if core_api_serialize
 @:meta(System.Serializable)
 #end
 @:keep @:struct @:nativeGen @:native("haxe.lang.Null") private class Nullable<T>