Skip to content

Commit 9efe6e4

Browse files
authored
Merge pull request #57 from mwhapples/CleanUp
Update MathCAT
2 parents 0f48d9d + f985d10 commit 9efe6e4

File tree

6 files changed

+39
-51
lines changed

6 files changed

+39
-51
lines changed

brailleblaster-app/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@
253253
</artifactItem>
254254
<artifactItem>
255255
<groupId>onl.mdw</groupId>
256-
<artifactId>mathcat4j-core</artifactId>
257-
<version>${mathcat4j.version}</version>
256+
<artifactId>mathcat4j-jni</artifactId>
257+
<version>${mathcat4j-jni.version}</version>
258258
<type>zip</type>
259259
<classifier>rules</classifier>
260260
</artifactItem>

brailleblaster-core/src/main/java/org/brailleblaster/search/DOMControl.kt

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,37 +16,22 @@
1616
package org.brailleblaster.search
1717

1818
import nu.xom.Node
19-
import nu.xom.Nodes
2019
import nu.xom.Text
20+
import org.brailleblaster.utd.internal.xml.FastXPath
2121
import org.brailleblaster.utd.internal.xml.XMLHandler
2222

2323
class DOMControl(private val click: Click) {
2424
val possiblesCorrectAttributes: MutableList<Node> = ArrayList()
2525
private val possiblesPastStart: MutableList<Node> = ArrayList()
2626

2727
init {
28-
val allNodes = click.initialView.mapElement.node.query("following::text()")
29-
nodesToArrayList(allNodes)
28+
val allNodes = FastXPath.following(click.initialView.mapElement.node).filterIsInstance<Text>()
29+
possiblesPastStart += allNodes
3030
if (SearchUtils.checkCorrectAttributes(click.initialView.mapElement.node, click)) {
3131
possiblesCorrectAttributes.add(0, click.initialView.mapElement.node)
3232
// following::text will not add the current element
3333
}
34-
getNodes(allNodes)
35-
}
36-
37-
private fun nodesToArrayList(nodes: Nodes) {
38-
for (i in 0 until nodes.size()) {
39-
possiblesPastStart.add(nodes[i])
40-
}
41-
}
42-
43-
private fun getNodes(nodes: Nodes) {
44-
for (i in 0 until nodes.size()) {
45-
val node = nodes[i]
46-
if (SearchUtils.checkCorrectAttributes(node, click)) {
47-
possiblesCorrectAttributes.add(node)
48-
}
49-
}
34+
possiblesCorrectAttributes += allNodes.filter { SearchUtils.checkCorrectAttributes(it, click) }
5035
}
5136

5237
fun searchNoView(array: List<Node>): String {

brailleblaster-debug-tools/src/main/kotlin/org/brailleblaster/debug/XMLDebugger.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ class XMLDebugger(private val parent: Shell, private val simpleManager: BBSimple
196196
if (n is nu.xom.Text) n = n.parent
197197
if (n == null) return
198198
curNode = n
199-
activeDocument = if (n is Document) n else Document(n.copy() as Element)
199+
activeDocument = n as? Document ?: Document(n.copy() as Element)
200200
if (!showBrlValue) UTDHelper.getDescendantBrlFast(activeDocument) { it.detach() }
201201
if (warnEmptyText) {
202202
FastXPath.descendant(activeDocument)

pom.xml

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ child.project.url.inherit.append.path="false">
4646
<revision>3.1.0</revision>
4747
<sha1/>
4848
<changelist>-SNAPSHOT</changelist>
49-
<wrappermavenplugin.version>3.3.2</wrappermavenplugin.version>
5049
<versions.plugin.version>2.18.0</versions.plugin.version>
5150
<maven.compiler.source>21</maven.compiler.source>
5251
<maven.compiler.target>21</maven.compiler.target>
@@ -60,7 +59,8 @@ child.project.url.inherit.append.path="false">
6059
<logback-core.version>1.5.20</logback-core.version>
6160
<logback-classic.version>1.5.20</logback-classic.version>
6261
<icu4j.version>77.1</icu4j.version>
63-
<mathcat4j.version>0.6.8-1</mathcat4j.version>
62+
<mathcat4j.version>1.0.0</mathcat4j.version>
63+
<mathcat4j-jni.version>0.7.2-0</mathcat4j-jni.version>
6464
<jlouis.version>c75db74718cea465f839f7cb5b4bcf716ba3e3e3</jlouis.version>
6565
<libembosser.version>1.4.3</libembosser.version>
6666
<jaxbapi.version>4.0.4</jaxbapi.version>
@@ -122,11 +122,21 @@ child.project.url.inherit.append.path="false">
122122
<dependencies>
123123
<dependency>
124124
<groupId>onl.mdw</groupId>
125-
<artifactId>mathcat4j-core</artifactId>
125+
<artifactId>mathcat4j-api</artifactId>
126126
</dependency>
127127
<dependency>
128128
<groupId>onl.mdw</groupId>
129-
<artifactId>mathcat4j-core</artifactId>
129+
<artifactId>mathcat4j-jni-loader-jna</artifactId>
130+
<scope>runtime</scope>
131+
</dependency>
132+
<dependency>
133+
<groupId>onl.mdw</groupId>
134+
<artifactId>mathcat4j-jni</artifactId>
135+
<scope>runtime</scope>
136+
</dependency>
137+
<dependency>
138+
<groupId>onl.mdw</groupId>
139+
<artifactId>mathcat4j-jni</artifactId>
130140
<classifier>rules</classifier>
131141
<type>zip</type>
132142
<scope>runtime</scope>
@@ -273,7 +283,7 @@ child.project.url.inherit.append.path="false">
273283
</dependency>
274284
<dependency>
275285
<groupId>org.graalvm.polyglot</groupId>
276-
<artifactId>js-community</artifactId>
286+
<artifactId>js</artifactId>
277287
<version>${graalvm.version}</version>
278288
<type>pom</type>
279289
</dependency>
@@ -324,26 +334,25 @@ child.project.url.inherit.append.path="false">
324334
</dependency>
325335
<dependency>
326336
<groupId>onl.mdw</groupId>
327-
<artifactId>mathcat4j-core</artifactId>
337+
<artifactId>mathcat4j-api</artifactId>
328338
<version>${mathcat4j.version}</version>
329-
<exclusions>
330-
<exclusion>
331-
<groupId>org.jetbrains.kotlin</groupId>
332-
<artifactId>kotlin-stdlib</artifactId>
333-
</exclusion>
334-
</exclusions>
335339
</dependency>
336340
<dependency>
337341
<groupId>onl.mdw</groupId>
338-
<artifactId>mathcat4j-core</artifactId>
339-
<version>${mathcat4j.version}</version>
342+
<artifactId>mathcat4j-jni-loader-jna</artifactId>
343+
<version>${mathcat4j-jni.version}</version>
344+
</dependency>
345+
<dependency>
346+
<groupId>onl.mdw</groupId>
347+
<artifactId>mathcat4j-jni</artifactId>
348+
<version>${mathcat4j-jni.version}</version>
349+
</dependency>
350+
<dependency>
351+
<groupId>onl.mdw</groupId>
352+
<artifactId>mathcat4j-jni</artifactId>
353+
<version>${mathcat4j-jni.version}</version>
340354
<classifier>rules</classifier>
341355
<type>zip</type>
342-
<exclusions>
343-
<exclusion>
344-
<groupId>org.jetbrains.kotlin</groupId>
345-
<artifactId>kotlin-stdlib</artifactId>
346-
</exclusion></exclusions>
347356
</dependency>
348357
<dependency>
349358
<groupId>org.jetbrains.kotlinx</groupId>
@@ -478,13 +487,6 @@ child.project.url.inherit.append.path="false">
478487

479488
<build>
480489
<plugins>
481-
<!-- Generate a maven wrapper script, similar to gradle wrapper -->
482-
<!-- Regenerate with wrapper:wrapper -->
483-
<plugin>
484-
<groupId>org.apache.maven.plugins</groupId>
485-
<artifactId>maven-wrapper-plugin</artifactId>
486-
<version>${wrappermavenplugin.version}</version>
487-
</plugin>
488490
<plugin>
489491
<groupId>org.jetbrains.kotlin</groupId>
490492
<artifactId>kotlin-maven-plugin</artifactId>

utd/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<!-- Needed for AsciiMathConverter -->
3030
<dependency>
3131
<groupId>org.graalvm.polyglot</groupId>
32-
<artifactId>js-community</artifactId>
32+
<artifactId>js</artifactId>
3333
<type>pom</type>
3434
</dependency>
3535
<dependency>

utils/src/main/kotlin/org/brailleblaster/utils/braille/MathCATUtils.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
package org.brailleblaster.utils.braille
1717

1818
import onl.mdw.mathcat4j.api.MathCat
19-
import onl.mdw.mathcat4j.core.mathCAT
19+
import onl.mdw.mathcat4j.api.MathCatLoader
2020
import java.util.concurrent.Callable
2121
import java.util.concurrent.Executors
2222

23+
private val mcManager = MathCatLoader.INSTANCE.mathCatFactory.orElseThrow().create()
2324
private val mathCATExecutor = Executors.newSingleThreadExecutor().also {
2425
Runtime.getRuntime().addShutdownHook(Thread(it::shutdown))
2526
}
2627

27-
fun <T> singleThreadedMathCAT(block: MathCat.() -> T): T = mathCATExecutor.submit(Callable { mathCAT(block) }).get()
28+
fun <T> singleThreadedMathCAT(block: MathCat.() -> T): T = mathCATExecutor.submit(Callable { mcManager.run { it.block() } }).get()

0 commit comments

Comments
 (0)