Skip to content

Commit

Permalink
remove Language from public view
Browse files Browse the repository at this point in the history
  • Loading branch information
kubukoz committed Oct 30, 2024
1 parent 4028f07 commit c17c3cf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 57 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
* limitations under the License.
*/

package org.polyvariant.treesitter4s.internal;
package org.polyvariant.treesitter4s.lowlevel;

import com.sun.jna.*;
import com.sun.jna.Structure.FieldOrder;
import org.polyvariant.treesitter4s.Language;

// todo: this could be a separate library (independent of Scala versions)
public interface TreeSitterLibrary extends Library {
interface TreeSitterLibrary extends Library {

// todo: extensible for languages
// long tree_sitter_scala();
Expand Down Expand Up @@ -53,6 +51,17 @@ public Tree(Pointer p) {
}
}

public static class Language extends PointerType {
public Language() {
super();
}

public Language(Pointer p) {
super(p);
}
}


// static

Parser ts_parser_new();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.polyvariant.treesitter4s.lowlevel

import com.sun.jna.*
import org.polyvariant.treesitter4s.internal.TreeSitterLibrary

object TreeSitterPlatform {

Expand All @@ -42,7 +41,7 @@ object TreeSitterPlatform {
}

trait LanguageWrapper {
def lang: org.polyvariant.treesitter4s.Language
def lang: TreeSitterLibrary.Language
}

type Language = LanguageWrapper
Expand All @@ -58,11 +57,11 @@ object TreeSitterPlatform {
val function = library.getFunction(s"tree_sitter_$languageName");

val langg = function
.invoke(classOf[org.polyvariant.treesitter4s.Language], Array())
.asInstanceOf[org.polyvariant.treesitter4s.Language]
.invoke(classOf[TreeSitterLibrary.Language], Array())
.asInstanceOf[TreeSitterLibrary.Language]

new LanguageWrapper {
def lang: org.polyvariant.treesitter4s.Language = {
def lang: TreeSitterLibrary.Language = {
// but we need to keep a reference to the library for... reasons
// probably related to, but not quite the same, as:
// https://github.com/java-native-access/jna/pull/1378
Expand Down

0 comments on commit c17c3cf

Please sign in to comment.