Skip to content

Commit

Permalink
mass replace objc with swift
Browse files Browse the repository at this point in the history
  • Loading branch information
cristibaluta committed Jun 5, 2014
1 parent f3d99f6 commit 2324935
Show file tree
Hide file tree
Showing 29 changed files with 227 additions and 229 deletions.
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ RELDIR=../../..

MODULES=ast type lexer common genxml parser typecore optimizer typeload \
codegen gencommon genas3 gencpp genjs genneko genphp genswf8 \
genswf9 genswf genjava gencs genobjc genpy interp dce filters typer matcher version main
genswf9 genswf genjava gencs genswift genpy interp dce filters typer matcher version main

ADD_REVISION=0

Expand Down Expand Up @@ -128,10 +128,6 @@ genas3.$(MODULE_EXT): type.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_E

gencommon.$(MODULE_EXT): type.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) ast.$(MODULE_EXT)

# genobjc.cmx: type.cmx lexer.cmx common.cmx codegen.cmx ast.cmx
#
# gencs.cmx: type.cmx lexer.cmx gencommon.cmx common.cmx codegen.cmx ast.cmx

gencpp.$(MODULE_EXT): type.$(MODULE_EXT) lexer.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) ast.$(MODULE_EXT)

gencs.$(MODULE_EXT): type.$(MODULE_EXT) lexer.$(MODULE_EXT) gencommon.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) ast.$(MODULE_EXT)
Expand All @@ -146,6 +142,8 @@ genphp.$(MODULE_EXT): type.$(MODULE_EXT) lexer.$(MODULE_EXT) common.$(MODULE_EXT

genpy.$(MODULE_EXT): type.$(MODULE_EXT) lexer.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) ast.$(MODULE_EXT)

genswift.$(MODULE_EXT): type.$(MODULE_EXT) lexer.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) ast.$(MODULE_EXT)

genswf.$(MODULE_EXT): type.$(MODULE_EXT) genswf9.$(MODULE_EXT) genswf8.$(MODULE_EXT) common.$(MODULE_EXT) ast.$(MODULE_EXT)

genswf8.$(MODULE_EXT): type.$(MODULE_EXT) lexer.$(MODULE_EXT) common.$(MODULE_EXT) codegen.$(MODULE_EXT) ast.$(MODULE_EXT)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![Haxe logo](http://ralcr.com/swift.png)
# [Hxobjc target](http://haxe.org)
# [Swift target for Haxe language](http://haxe.org)

This fork contains the Hxobjc target.
This fork contains the Swift target.
[![Build Status](https://travis-ci.org/HaxeFoundation/haxe.png?branch=development)](https://travis-ci.org/HaxeFoundation/haxe)

Haxe is an open source toolkit that allows you to easily build cross-platform tools and applications that target many mainstream platforms. The Haxe toolkit includes:
Expand Down
12 changes: 6 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ echo "Build CocoaTouch demos..."
echo " "

cd ../hxcocoa/demos/Hello
# ./../../../haxe/haxe compile.hxml
./../../../haxe/haxe compile.hxml

cd ../Busses
# cd ../Busses
# ./../../../haxe/haxe compile.hxml

cd ../PiratePig
# cd ../PiratePig
# ./../../../haxe/haxe compile.hxml

cd ../WWX
./../../../haxe/haxe compile.hxml
# cd ../WWX
# ./../../../haxe/haxe compile.hxml

echo " "
echo "Build the playground..."
Expand All @@ -36,4 +36,4 @@ echo "Build utests..."
echo " "

cd ..
# ./haxe/haxe -cp haxe/tests -objc utests -main unit.Test -dce no -D haxeJSON --times
# ./haxe/haxe -cp haxe/tests -swift utests -main unit.Test -dce no -D haxeJSON --times
71 changes: 36 additions & 35 deletions common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type platform =
| Cpp
| Cs
| Java
| ObjC
| Swift
| Python

(**
Expand Down Expand Up @@ -152,17 +152,17 @@ type context = {
mutable net_std : string list;
net_path_map : (path,string list * string list * string) Hashtbl.t;
mutable js_gen : (unit -> unit) option;
mutable objc_platform : string;
mutable objc_libs : string list;(* A list of custom frameworks that you wish to link with your project *)
mutable objc_version : float;
mutable objc_bundle_version : float;
mutable objc_bundle_name : string option;
mutable objc_identifier : string option;
mutable objc_owner : string option;
mutable objc_linker_flags : string list;
mutable objc_frameworks : string list;
mutable swift_platform : string;
mutable swift_libs : string list;(* A list of custom frameworks that you wish to link with your project *)
mutable swift_version : float;
mutable swift_bundle_version : float;
mutable swift_bundle_name : string option;
mutable swift_identifier : string option;
mutable swift_owner : string option;
mutable swift_linker_flags : string list;
mutable swift_frameworks : string list;
mutable ios_orientations : string list;
mutable objc_supporting_files : string option;
mutable swift_supporting_files : string option;
(* typing *)
mutable basic : basic_types;
memory_marker : float array;
Expand Down Expand Up @@ -402,7 +402,7 @@ module MetaInfo = struct
| HxGen -> ":hxGen",("Annotates that an extern class was generated by Haxe",[Platforms [Java;Cs]; UsedOnEither [TClass;TEnum]])
| IfFeature -> ":ifFeature",("Causes a field to be kept by DCE if the given feature is part of the compilation",[HasParam "Feature name";UsedOn TClassField])
| Impl -> ":impl",("Used internally to mark abstract implementation fields",[UsedOn TAbstractField; Internal])
| Include -> ":include",("",[Platforms [Cpp;ObjC]])
| Include -> ":include",("",[Platforms [Cpp;Swift]])
| PythonImport -> ":pythonImport",("Generates python import statement for extern classes",[Platforms [Python]; UsedOn TClass])
| Include -> ":include",("",[Platform Cpp])
| InitPackage -> ":initPackage",("?",[])
Expand Down Expand Up @@ -468,13 +468,13 @@ module MetaInfo = struct
| Unsafe -> ":unsafe",("Declares a class, or a method with the C#'s 'unsafe' flag",[Platform Cs; UsedOnEither [TClass;TClassField]])
| Usage -> ":usage",("?",[])
| Used -> ":used",("Internally used by DCE to mark a class or field as used",[Internal])
| C -> ":c",("Mark a C method in Objective-C code",[Platform ObjC])
| Category -> ":category",("Converts a class to an Objective-C category of another class",[Platform ObjC])
| GetterBody -> ":getterBody",("Set the code inside a getter method",[UsedOn TClassField;Platform ObjC])
| Import -> ":import",("Generates an #import statement for a native class",[Platform ObjC])
| Framework -> ":framework",("Generates an #import for the framework instead the class path",[Platform ObjC])
| Selector -> ":sel",("Use this as a signature instead the method arguments",[Platform ObjC])
| Weak -> ":weak",("Declaring a property with weak reference instead strong",[Platform ObjC])
| C -> ":c",("Mark a C method in Objective-C code",[Platform Swift])
| Category -> ":category",("Converts a class to an Objective-C category of another class",[Platform Swift])
| GetterBody -> ":getterBody",("Set the code inside a getter method",[UsedOn TClassField;Platform Swift])
| Import -> ":import",("Generates an #import statement for a native class",[Platform Swift])
| Framework -> ":framework",("Generates an #import for the framework instead the class path",[Platform Swift])
| Selector -> ":sel",("Use this as a signature instead the method arguments",[Platform Swift])
| Weak -> ":weak",("Declaring a property with weak reference instead strong",[Platform Swift])
| Void -> ":void",("Use Cpp native 'void' return type",[Platform Cpp])
| Last -> assert false
(* do not put any custom metadata after Last *)
Expand Down Expand Up @@ -681,19 +681,20 @@ let get_config com =
pf_can_skip_non_nullable_argument = true;
pf_ignore_unsafe_cast = true;
}
| ObjC ->
| Swift ->
{
pf_static = false;
pf_sys = true;
pf_locals_scope = false;
pf_captured_scope = true;
pf_unique_locals = false;
pf_can_init_member = (fun _ -> false);
pf_capture_policy = CPNone;
pf_pad_nulls = false;
pf_add_final_return = true;
pf_overload = true;
pf_pattern_matching = false;
pf_can_skip_non_nullable_argument = true;
pf_ignore_unsafe_cast = true;
}

let memory_marker = [|Unix.time()|]
Expand Down Expand Up @@ -736,17 +737,17 @@ let create v args =
neko_libs = [];
php_prefix = None;
js_gen = None;
objc_platform = "universal";
objc_libs = [];
objc_version = 6.0;
objc_bundle_version = 1.0;
objc_identifier = None;
objc_owner = None;
objc_bundle_name = None;
swift_platform = "universal";
swift_libs = [];
swift_version = 6.0;
swift_bundle_version = 1.0;
swift_identifier = None;
swift_owner = None;
swift_bundle_name = None;
ios_orientations = [];
objc_supporting_files = None;
objc_linker_flags = [];
objc_frameworks = [];
swift_supporting_files = None;
swift_linker_flags = [];
swift_frameworks = [];
load_extern_type = [];
defines_signature = None;
get_macros = (fun() -> None);
Expand Down Expand Up @@ -808,7 +809,7 @@ let platforms = [
Cpp;
Cs;
Java;
ObjC;
Swift;
]

let platform_name = function
Expand All @@ -821,7 +822,7 @@ let platform_name = function
| Cpp -> "cpp"
| Cs -> "cs"
| Java -> "java"
| ObjC -> "objc"
| Swift -> "swift"
| Python -> "python"

let flash_versions = List.map (fun v ->
Expand Down Expand Up @@ -856,13 +857,13 @@ let flash_version_tag = function
| 17.0 -> 28
| v -> failwith ("Invalid SWF version " ^ string_of_float v)

let objc_ios_versions = List.map (fun v ->
let swift_ios_versions = List.map (fun v ->
let maj = int_of_float v in
let min = int_of_float (mod_float (v *. 10.) 10.) in
v, string_of_int maj ^ (if min = 0 then "" else "_" ^ string_of_int min)
) [4.0;4.3;5.0;6.0]

let objc_osx_versions = List.map (fun v ->
let swift_osx_versions = List.map (fun v ->
let maj = int_of_float v in
let min = int_of_float (mod_float (v *. 10.) 10.) in
v, string_of_int maj ^ (if min = 0 then "" else "_" ^ string_of_int min)
Expand Down
Loading

0 comments on commit 2324935

Please sign in to comment.