or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

array-runtime.mdboxing-unboxing.mdconcurrent-collections.mdindex.mdmathematical-support.mdreference-types.md
tile.json

tessl/maven-org-scala-native--auxlib-native0-5-3

Auxiliary libraries for Scala Native runtime providing essential runtime support including boxed types, concurrent collections, and utility functions

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.scala-native/auxlib_native0.5_3@0.5.x

To install, run

npx @tessl/cli install tessl/maven-org-scala-native--auxlib-native0-5-3@0.5.0

index.mddocs/

Scala Native Auxlib

The auxlib library provides essential runtime support components for Scala Native, including boxed primitive types, concurrent collection infrastructure, array utilities, reference type wrappers, and mathematical abstractions. This low-level library serves as a foundational layer for Scala Native's runtime system, enabling proper interoperability between Scala's type system and native code execution.

Package Information

  • Package Name: org.scala-native:auxlib_native0.5_3
  • Package Type: maven
  • Language: Scala
  • Installation: Add to build.sbt: libraryDependencies += "org.scala-native" %%% "auxlib" % "0.5.7"

Core Imports

import scala.runtime.BoxesRunTime
import scala.runtime.{BooleanRef, IntRef, ObjectRef}
import scala.math.ScalaNumber
import scala.collection.concurrent.{BasicNode, MainNode}

Basic Usage

import scala.runtime.BoxesRunTime
import scala.runtime.IntRef

// Boxing and unboxing primitives
val boxedInt = BoxesRunTime.boxToInteger(42)
val unboxedInt = BoxesRunTime.unboxToInt(boxedInt)

// Using reference types for mutable variables
val intRef = IntRef.create(10)
intRef.elem = 20
println(intRef.elem) // 20

// Arithmetic operations on boxed values
val a = BoxesRunTime.boxToInteger(5)
val b = BoxesRunTime.boxToInteger(3)
val sum = BoxesRunTime.add(a, b)
val result = BoxesRunTime.unboxToInt(sum) // 8

Architecture

The auxlib library is organized into five main functional areas:

  • Boxing/Unboxing System: Complete primitive type boxing with comprehensive operators for arithmetic, bitwise, and logical operations
  • Reference Types: Mutable and volatile reference wrappers for all primitive and object types
  • Array Utilities: Array cloning support for all primitive array types
  • Concurrent Collection Infrastructure: Base classes and atomic field updaters for lock-free concurrent data structures
  • Mathematical Abstractions: Base classes for Scala's numeric type hierarchy

This design provides the essential runtime infrastructure that bridges Scala language features with native compilation and execution models.

Capabilities

Boxing and Unboxing Operations

Comprehensive boxing/unboxing utilities with arithmetic, bitwise, and logical operators for primitive types. Handles type coercion and provides runtime support for Scala's unified type system.

object BoxesRunTime {
  def boxToInteger(v: Int): java.lang.Integer
  def unboxToInt(o: java.lang.Object): Int
  def add(arg1: java.lang.Object, arg2: java.lang.Object): java.lang.Object
  def equals(x: java.lang.Object, y: java.lang.Object): Boolean
}

Boxing and Unboxing

Reference Type Wrappers

Mutable and volatile reference wrappers for all primitive types and objects. Provides thread-safe access patterns and atomic operations support.

class IntRef(var elem: Int) extends Serializable
object IntRef {
  def create(elem: Int): IntRef
  def zero(): IntRef
}

class VolatileIntRef(@volatile var elem: Int) extends Serializable

Reference Types

Array Runtime Support

Array cloning utilities supporting all primitive array types and object arrays with proper type preservation.

object ArrayRuntime {
  def cloneArray(array: Array[Int]): Array[Int]
  def cloneArray(array: Array[java.lang.Object]): Array[java.lang.Object]
}

Array Runtime

Concurrent Collection Infrastructure

Base classes and atomic field updaters for building lock-free concurrent data structures. Provides the foundation for Scala's concurrent collections.

abstract class BasicNode {
  def string(lev: Int): String
}

abstract class MainNode[K <: AnyRef, V <: AnyRef] extends BasicNode {
  def cachedSize(ct: Object): Int
  def knownSize(): Int
}

Concurrent Collections

Mathematical Number Support

Abstract base classes for Scala's numeric type hierarchy, providing foundation for custom numeric types and mathematical operations.

abstract class ScalaNumber extends java.lang.Number {
  protected def isWhole(): Boolean
  def underlying(): Object
}

Mathematical Support

Types

Common Reference Types

class BooleanRef(var elem: Boolean) extends Serializable
class CharRef(var elem: Char) extends Serializable  
class ByteRef(var elem: Byte) extends Serializable
class ShortRef(var elem: Short) extends Serializable
class IntRef(var elem: Int) extends Serializable
class LongRef(var elem: Long) extends Serializable
class FloatRef(var elem: Float) extends Serializable
class DoubleRef(var elem: Double) extends Serializable
class ObjectRef[A](var elem: A) extends Serializable

Volatile Reference Types

class VolatileBooleanRef(@volatile var elem: Boolean) extends Serializable
class VolatileIntRef(@volatile var elem: Int) extends Serializable
class VolatileObjectRef[A](@volatile var elem: A) extends Serializable

Concurrent Collection Base Types

abstract class BasicNode
abstract class MainNode[K <: AnyRef, V <: AnyRef] extends BasicNode
abstract class INodeBase[K <: AnyRef, V <: AnyRef](generation: Gen) extends BasicNode
abstract class CNodeBase[K <: AnyRef, V <: AnyRef] extends MainNode[K, V]