-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make some start at wasm support (behind property). It doesn't work yet
due to some runtime error with node. It is not clear why it fails (there is no error message)
- Loading branch information
Showing
58 changed files
with
330 additions
and
143 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
142 changes: 142 additions & 0 deletions
142
...commonDom/kotlin/nl/adaptivity/xmlutil/core/impl/multiplatform/multiplatform.commonDom.kt
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,142 @@ | ||
/* | ||
* Copyright (c) 2023. | ||
* | ||
* This file is part of xmlutil. | ||
* | ||
* This file is licenced to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You should have received a copy of the license with the source distribution. | ||
* Alternatively, you may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package nl.adaptivity.xmlutil.core.impl.multiplatform | ||
|
||
import kotlin.reflect.KClass | ||
|
||
public actual abstract class Reader { | ||
public actual open fun read(): Int { | ||
val b = CharArray(1) | ||
if (read(b, 0, 1) < 0) return -1 | ||
return b[0].code | ||
} | ||
|
||
public actual abstract fun read(buf: CharArray, offset: Int, len: Int): Int | ||
} | ||
|
||
public actual interface AutoCloseable { | ||
public actual fun close() | ||
} | ||
|
||
public actual interface Closeable : AutoCloseable | ||
|
||
public actual inline fun <T : Closeable?, R> T.use(block: (T) -> R): R { | ||
var exception: Throwable? = null | ||
try { | ||
return block(this) | ||
} catch (e: Throwable) { | ||
exception = e | ||
throw e | ||
} finally { | ||
when { | ||
this == null -> {} | ||
exception == null -> close() | ||
else -> | ||
try { | ||
close() | ||
} catch (closeException: Throwable) { | ||
// cause.addSuppressed(closeException) // ignored here | ||
} | ||
} | ||
} | ||
} | ||
|
||
public actual val KClass<*>.maybeAnnotations: List<Annotation> get() = emptyList() | ||
|
||
public actual abstract class Writer : Appendable { | ||
public open fun write(text: String) { | ||
append(text) | ||
} | ||
|
||
override fun append(value: CharSequence?): Appendable { | ||
return append(value, 0, value?.length ?: 0) | ||
} | ||
|
||
/** Write buffers to the underlying file (where valid). */ | ||
public open fun flush() {} | ||
} | ||
|
||
public actual open class StringWriter : Writer() { | ||
private val buffer = StringBuilder() | ||
override fun write(text: String) { | ||
buffer.append(text) | ||
} | ||
|
||
override fun toString(): String { | ||
return buffer.toString() | ||
} | ||
|
||
override fun append(value: Char): Appendable = apply { | ||
buffer.append(value) | ||
} | ||
|
||
override fun append(value: CharSequence?): Appendable = apply { | ||
buffer.append(value) | ||
} | ||
|
||
override fun append( | ||
value: CharSequence?, | ||
startIndex: Int, | ||
endIndex: Int | ||
): Appendable = apply { | ||
buffer.append(value, startIndex, endIndex) | ||
} | ||
} | ||
|
||
/* | ||
public actual abstract class Reader { | ||
public actual open fun read(): Int { | ||
val b = CharArray(1) | ||
if (read(b, 0, 1) < 0) return -1 | ||
return b[0].code | ||
} | ||
public actual abstract fun read(buf: CharArray, offset: Int, len: Int): Int | ||
} | ||
*/ | ||
|
||
public actual open class StringReader(private val source: CharSequence) : Reader() { | ||
|
||
public actual constructor(source: String) : this(source as CharSequence) | ||
|
||
private var pos: Int = 0 | ||
|
||
override fun read(): Int = when { | ||
pos >= source.length -> -1 | ||
else -> source[pos++].code | ||
} | ||
|
||
override fun read(buf: CharArray, offset: Int, len: Int): Int { | ||
if (pos >= source.length) return -1 | ||
val count = minOf(len, source.length - pos) | ||
for (i in 0 until count) { | ||
buf[offset + i] = source[pos + i] | ||
} | ||
pos += count | ||
return count | ||
} | ||
} | ||
|
||
public actual annotation class Language actual constructor( | ||
actual val value: String, | ||
actual val prefix: String, | ||
actual val suffix: String | ||
) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...daptivity/xmlutil/util/CompactFragment.kt → ...daptivity/xmlutil/util/CompactFragment.kt
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2021. | ||
* Copyright (c) 2023. | ||
* | ||
* This file is part of xmlutil. | ||
* | ||
|
2 changes: 1 addition & 1 deletion
2
...y/xmlutil/util/XMLFragmentStreamReader.kt → ...y/xmlutil/util/XMLFragmentStreamReader.kt
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (c) 2021. | ||
* Copyright (c) 2023. | ||
* | ||
* This file is part of xmlutil. | ||
* | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
Oops, something went wrong.