-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf95826
commit 259cb2e
Showing
14 changed files
with
869 additions
and
830 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package tlcodegen | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
func (trw *TypeRWBool) PhpClassName(withPath bool, bare bool) string { | ||
return "boolean" | ||
} | ||
|
||
func (trw *TypeRWBool) PhpClassNameReplaced() bool { | ||
return true | ||
} | ||
|
||
func (trw *TypeRWBool) PhpTypeName(withPath bool, bare bool) string { | ||
return trw.PhpClassName(withPath, true) | ||
} | ||
|
||
func (trw *TypeRWBool) PhpGenerateCode(code *strings.Builder, bytes bool) error { | ||
return fmt.Errorf("boolean doesn't have php code") | ||
} | ||
|
||
func (trw *TypeRWBool) PhpDefaultValue() string { | ||
return "false" | ||
} | ||
|
||
func (trw *TypeRWBool) PhpIterateReachableTypes(reachableTypes *map[*TypeRWWrapper]bool) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package tlcodegen | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
func (trw *TypeRWMaybe) PhpClassName(withPath bool, bare bool) string { | ||
target := trw.getInnerTarget() | ||
return "maybe_" + target.t.trw.PhpClassName(withPath, target.bare) | ||
} | ||
|
||
func (trw *TypeRWMaybe) PhpClassNameReplaced() bool { | ||
return true | ||
} | ||
|
||
func (trw *TypeRWMaybe) PhpTypeName(withPath bool, bare bool) string { | ||
target := trw.getInnerTarget() | ||
return target.t.trw.PhpTypeName(withPath, target.t.PHPIsBare()) + "|null" | ||
} | ||
|
||
func (trw *TypeRWMaybe) getInnerTarget() Field { | ||
if inner, ok := trw.element.t.trw.(*TypeRWMaybe); ok { | ||
return inner.getInnerTarget() | ||
} else { | ||
return trw.element | ||
} | ||
} | ||
|
||
func (trw *TypeRWMaybe) PhpGenerateCode(code *strings.Builder, bytes bool) error { | ||
return fmt.Errorf("maybe doesn't have php code") | ||
} | ||
|
||
func (trw *TypeRWMaybe) PhpDefaultValue() string { | ||
return "null" | ||
} | ||
|
||
func (trw *TypeRWMaybe) PhpIterateReachableTypes(reachableTypes *map[*TypeRWWrapper]bool) { | ||
trw.element.t.PhpIterateReachableTypes(reachableTypes) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package tlcodegen | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
func (trw *TypeRWPrimitive) PhpClassName(withPath bool, bare bool) string { | ||
switch trw.goType { | ||
case "int32", "int64", "uint32": | ||
return "int" | ||
case "string": | ||
return "string" | ||
case "float32", "float64": | ||
return "float" | ||
default: | ||
return fmt.Sprintf("<? %s>", trw.tlType) | ||
} | ||
} | ||
|
||
func (trw *TypeRWPrimitive) PhpClassNameReplaced() bool { | ||
return true | ||
} | ||
|
||
func (trw *TypeRWPrimitive) PhpTypeName(withPath bool, bare bool) string { | ||
return trw.PhpClassName(withPath, true) | ||
} | ||
|
||
func (trw *TypeRWPrimitive) PhpGenerateCode(code *strings.Builder, bytes bool) error { | ||
return fmt.Errorf("primitives don't have php code") | ||
} | ||
|
||
func (trw *TypeRWPrimitive) PhpDefaultValue() string { | ||
switch trw.goType { | ||
case "int32", "int64", "uint32": | ||
return "0" | ||
case "string": | ||
return "''" | ||
case "float32", "float64": | ||
return "0.0" | ||
default: | ||
return fmt.Sprintf("<? %s>", trw.tlType) | ||
} | ||
} | ||
|
||
func (trw *TypeRWPrimitive) PhpIterateReachableTypes(reachableTypes *map[*TypeRWWrapper]bool) {} |
Oops, something went wrong.