Skip to content
This repository was archived by the owner on Nov 24, 2020. It is now read-only.

Feature/kt jetpack #62

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions src/codegen_types/array.cr
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,6 @@ module AST
def kt_decode(expr, desc)
String.build do |io|
io << "gson.fromJson<ArrayList<#{base.kt_native_type}>>(#{expr}.getJSONArray(\"result\")?.toString(), object : TypeToken<ArrayList<#{base.kt_native_type}>>() { }.type) \n"
# io << "ArrayList<#{base.kt_native_type}>().apply {\n"
# io << " for (i in 0 until #{expr}.length()) {\n"
# if base.is_a? AST::ArrayType
# io << " add(#{base.kt_native_type}.fromJsonArray(#{expr}.getJSONArray(i)))\n"
# elsif base.is_a? AST::StructType
# io << " add(#{base.kt_native_type}.fromJson(#{expr}.getJSONObject(i)))\n"
# else
# io << " add(#{base.kt_decode(expr, "i")})"
# end
# io << " }\n"
# io << ""
end
end

Expand Down
8 changes: 4 additions & 4 deletions src/codegen_types/hex.cr
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ module AST

# KOTLIN
def kt_decode(expr, desc)
raise "Not implemented"
"#{expr}.getString(#{desc})"
end

def kt_encode(expr, desc)
raise "Not implemented"
"#{expr}"
end

def kt_native_type
raise "Not implemented"
"String"
end

def kt_return_type_name
raise "Not implemented"
"hex"
end
# KOTLIN
end
Expand Down
6 changes: 3 additions & 3 deletions src/codegen_types/struct.cr
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ module AST
io << "#{suffix} \n"
index += 1
end
io << "): Serializable {\n\n"
io << "): Serializable {\n"
io << " companion object {\n"
io << " fun fromJson(jsonToParse : JSONObject): #{kt_native_type} {\n"
io << " return gson.fromJson(jsonToParse.toString(), #{name}::class.java)\n"
Expand All @@ -112,8 +112,8 @@ module AST

toJsonExpr = "this@#{name}"
io << " fun toJson(): JSONObject {\n"
io << " return JSONObject(gson.toJson(this))"
io << " }"
io << " return JSONObject(gson.toJson(this))\n"
io << " }\n"
io << "}"
end
end
Expand Down
Binary file added src/main
Binary file not shown.
1 change: 1 addition & 0 deletions src/main.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ require "./syntax/parser"
require "./semantic/ast_semantic"
require "./target/java_android"
require "./target/kt_android"
require "./target/kt_jetpack_android"
require "./target/swift_ios"
require "./target/typescript_nodeserver"
require "./target/typescript_nodeclient"
Expand Down
Loading