Skip to content

Releases: jokade/swog

V0.0.6

12 Jan 22:42
Compare
Choose a tag to compare
V0.0.6 Pre-release
Pre-release

Release Notes V0.0.6

CObj

  • switch to full wrapper semantics, i.e. every CObj takes a pointer to the underlying object as its sole argument for the primary constructor
  • provide PoolZone

V0.0.5

09 Sep 16:07
Compare
Choose a tag to compare
V0.0.5 Pre-release
Pre-release

Release Notes V0.0.5

CObj

  • All public symbols related to CObj are now located in package scalanative.native.cobj

  • Support control how external names are generated for methods in @CObj via namingConvention parameter:

    • NamingConvention.None uses the method name unmodified:

      @CObj(namingConvention = NamingConvention.None)
      class Foo {
        def fooBar(): Unit = extern
      }

      => external name: Foo_fooBar

    • NamingConvention.SnakeCase(default):
      => external name: Foo_foo_bar

    • NamingConvention.PascalCase:
      => external name: Foo_FooBar

  • Support methods without argument lists, i.e.

    @ObjC
    class Foo {
      def bar: Int = extern
    }

ObjC

  • All symbols related to ObjC are now part of package scalanative.native.objc (#6).

  • The ObjC selector is no longer derived using the argument names of the Scala method; instead the selector now is only derived from the method name, using snake_case semantics (#5). Examples:

    • def foo(): Unit = extern => selector: foo
    • def foo_(i: Int): Unit = extern => selector foo:
    • def foo_bar_(i: Int, b: Boolean) => selector foo:bar:
  • Handle setters with type args correctly (#8).

  • Support auto-retain/release on public vars of @ScalaObjCclasses via @retain:

    @ScalaObjC
    class Foo(self: NSObject) extends NSObject {
      @retain
      var bar: NSObject = _
    }

    On assignment to bar from ObjC, release() is called on the old value, and retain() is called on the new one (#9).

  • Support ObjC Blocks (#12). If a ObjC method takes a Block:

    typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
    - (NSArray<ObjectType> *)sortedArrayUsingComparator:(NSComparator)cmptr;

    it can no be called from Scala using a lambda:

    // method signature in Scala
    def sortedArrayUsingComparator(comparator: Block2[T,T,NSComparisonResult]): NSArray[T] = extern
    
    // usage:
    val strings = NSArray(ns"string2", ns"string1",ns"string3") 
    
    val sorted = strings.sortedArrayUsingComparator_(
      // lambda, mapped to the require Block2 via implicit conversion
      (block: Block, a: NSString, b: NSString) => a.string.compare(b.string)
    )

V0.0.4

05 Aug 10:00
Compare
Choose a tag to compare
V0.0.4 Pre-release
Pre-release

This release adds support for interop with Objective-C.

V0.0.3

01 Feb 03:42
013f206
Compare
Choose a tag to compare
V0.0.3 Pre-release
Pre-release

Release Notes

  • allow Out[] params for object methods

  • provide returnsSelf annotation to avoid wrapper creation if the returned reference is the same object:

    @CObj
    class Foo {
      @CObj.returnsSelf
      def foo(): Foo = extern
    }
    
    val f1 = new Foo
    val f2 = f1.foo()

    f1.foo() returns f1, not a new Foo, i.e. f1 and f2 are the same object.

  • Mutable and updatesSelf annotations allow to update the C reference hold by a wrapper object.
    Useful for data structures, where an update operation possibly returns a new C reference:

    @CObj.Mutable
    class GList(var __ref: CObj.Ref[Byte]) {
      @CObj.updatesThis
      def append(elem: Ptr[Byte]): GList = extern
    }
  • add nullable annotation to suppress wrapping if the external function returns null:

    @CObj
    class Foo {
      @CObj.nullable
      def foo(): Foo = extern
    }

    If the external call for Foo.foo() returns null, the result of Foo.foo() is also null,
    instead of new Foo(null).

V0.0.2

13 Jan 23:10
Compare
Choose a tag to compare
V0.0.2 Pre-release
Pre-release

Release Notes

  • add CObj.implicits.RichRef to convert from Ref[T] to Ptr[T]:
    import scalanative.native._
    import CObj.implicits._
    
    class Foo extends CRef[Struct1[Int]] {
      def bar: Int = !__ref.toPtr._1
    }```
    
  • provide Out[T] to simplify handling of output paramters defined on an external function:
    def foo(in: Int)(implicit error: Out[GError]) : Int = extern
    
    Zone{ implicit z =>
      val err = Out.alloc[GError]
      foo(42)
      if(err.isDefined) {
        err.value.get ...
      }
    }```
    
  • handle external function results that require CObj wrappers:
    @CObj
    class Foo {
      // the pointer returned by the external function is automatically wrapped into a Foo()
      def bar(): Foo = extern
    }```
    
  • allow CObj classes to extend other CObj classes

V0.0.1

11 Jan 17:35
Compare
Choose a tag to compare
V0.0.1 Pre-release
Pre-release
Merge branch 'master' of github.com:jokade/scalanative-obj-interop