Skip to content

Commit

Permalink
make >>> public
Browse files Browse the repository at this point in the history
  • Loading branch information
bastie committed Oct 28, 2023
1 parent 0ca13cc commit 2ab9da9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ Abstract classes are implemented as interface with default methods.

The Java length property of an array is mapped over a readonly computed Swift property with result of Swift count property.

#### assert

Instead of `assert` use the `guard` with function `fatalError`.

#### blocks of statements

In Java blocks are between curly braces {}. Swift need the `do` keyword before the open brace.
Expand Down Expand Up @@ -149,6 +153,12 @@ All types in package java.lang doesn't need to import in Java. One solution is t

Also if default Swing type exists it is extended instead Java implementation is ported, see String type as example.

#### keyword masking

The best way is to rename variables and types in Java before collision with Swift keywords. But you can also variable names mask with backtick like:

let `in` : Int

#### Map

Java Map is similar to dictionary type in Swift
Expand Down
10 changes: 5 additions & 5 deletions Sources/JavApi/lang/Operator+Java.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
*/
infix operator >>> : BitwiseShiftPrecedence

func >>> (lhs: Int, rhs: Int) -> Int {
public func >>> (lhs: Int, rhs: Int) -> Int {
return Int(bitPattern: UInt(bitPattern: lhs) >> UInt(rhs))
}
func >>> (lhs: Int64, rhs: Int64) -> Int64 {
public func >>> (lhs: Int64, rhs: Int64) -> Int64 {
return Int64(bitPattern: UInt64(bitPattern: lhs) >> UInt64(rhs))
}
func >>> (lhs: Int32, rhs: Int32) -> Int32 {
public func >>> (lhs: Int32, rhs: Int32) -> Int32 {
return Int32(bitPattern: UInt32(bitPattern: lhs) >> UInt32(rhs))
}
func >>> (lhs: Int16, rhs: Int16) -> Int16 {
public func >>> (lhs: Int16, rhs: Int16) -> Int16 {
return Int16(bitPattern: UInt16(bitPattern: lhs) >> UInt16(rhs))
}
func >>> (lhs: Int8, rhs: Int8) -> Int8 {
public func >>> (lhs: Int8, rhs: Int8) -> Int8 {
return Int8(bitPattern: UInt8(bitPattern: lhs) >> UInt8(rhs))
}

0 comments on commit 2ab9da9

Please sign in to comment.