Releases: jokade/swog
V0.0.6
V0.0.5
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
vianamingConvention
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
=> selectorfoo:
def foo_bar_(i: Int, b: Boolean)
=> selectorfoo:bar:
-
Handle setters with type args correctly (#8).
-
Support auto-retain/release on public vars of
@ScalaObjC
classes 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, andretain()
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
V0.0.3
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()
returnsf1
, not a newFoo
, i.e.f1
andf2
are the same object. -
Mutable
andupdatesSelf
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 ofFoo.foo()
is also null,
instead ofnew Foo(null)
.
V0.0.2
Release Notes
- add
CObj.implicits.RichRef
to convert fromRef[T]
toPtr[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