Skip to content

Commit

Permalink
refactor: make WeakHashMap internal
Browse files Browse the repository at this point in the history
  • Loading branch information
lppedd authored and ftomassetti committed Sep 6, 2024
1 parent b7a54cb commit 8dd5d45
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Copyright 2024-present Strumenta and contributors, licensed under BSD 3-Clause.
package com.strumenta.antlrkotlin.runtime

public expect class WeakHashMap<K, V>() : MutableMap<K, V> {
internal expect class WeakHashMap<K, V>() : MutableMap<K, V> {
override val size: Int
override val entries: MutableSet<MutableMap.MutableEntry<K, V>>
override val keys: MutableSet<K>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2017-present Strumenta and contributors, licensed under Apache 2.0.
// Copyright 2024-present Strumenta and contributors, licensed under BSD 3-Clause.

package com.strumenta.antlrkotlin.runtime

// Note(Edoardo): this is implemented as an HashMap in the JS target,
// so let's keep it as it is
public actual typealias WeakHashMap<K, V> = HashMap<K, V>
@Suppress("ACTUAL_WITHOUT_EXPECT")
internal actual typealias WeakHashMap<K, V> = HashMap<K, V>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright 2017-present Strumenta and contributors, licensed under Apache 2.0.
// Copyright 2024-present Strumenta and contributors, licensed under BSD 3-Clause.

package com.strumenta.antlrkotlin.runtime

import java.util.WeakHashMap as JavaWeakHashMap

public actual typealias WeakHashMap<K, V> = JavaWeakHashMap<K, V>
@Suppress("ACTUAL_WITHOUT_EXPECT")
internal actual typealias WeakHashMap<K, V> = JavaWeakHashMap<K, V>
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright 2017-present Strumenta and contributors, licensed under Apache 2.0.
// Copyright 2024-present Strumenta and contributors, licensed under BSD 3-Clause.

package com.strumenta.antlrkotlin.runtime

// TODO(Edoardo): implement real weak keys.
// See kotlinlang.org/api/latest/jvm/stdlib/kotlin.native.ref
// for classes and functions useful for a possible implementation
public actual typealias WeakHashMap<K, V> = HashMap<K, V>
@Suppress("ACTUAL_WITHOUT_EXPECT")
internal actual typealias WeakHashMap<K, V> = HashMap<K, V>
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
package com.strumenta.antlrkotlin.runtime

// TODO(Edoardo): implement real weak keys
public actual typealias WeakHashMap<K, V> = HashMap<K, V>
@Suppress("ACTUAL_WITHOUT_EXPECT")
internal actual typealias WeakHashMap<K, V> = HashMap<K, V>

0 comments on commit 8dd5d45

Please sign in to comment.