Skip to content

Commit 8859e9b

Browse files
committed
use haxe5 fromNull for guid ints.
1 parent ea717ee commit 8859e9b

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

cdb/Module.hx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ class Module {
484484
kind : FFun({
485485
args : [],
486486
ret : null,
487-
expr : macro return this.isNull() ? null : $i{modName}.$tableName.getUID(this),
487+
expr : macro return #if haxe5 this == null #else this.isNull() #end ? null : $i{modName}.$tableName.getUID(this),
488488
})
489489
});
490490
fields.push({
@@ -505,15 +505,15 @@ class Module {
505505
kind : FFun({
506506
args : [{ name : "kind", type : TPath({ name : tkind, pack : [] }) }],
507507
ret : TPath({ name : tname+"Guid", pack : [] }),
508-
expr : macro return kind == null ? cdb.Types.GuidInt.getNull() : cast $i{modName}.$tableName.get(kind).$guidField.toInt(),
508+
expr : macro return kind == null ? #if haxe5 null #else cdb.Types.GuidInt.getNull() #end : cast $i{modName}.$tableName.get(kind).$guidField.toInt(),
509509
})
510510
});
511511
}
512512
types.push({
513513
pos : pos,
514514
name : tname+"Guid",
515515
pack : curMod,
516-
meta : [{ name : ":forward", params : [], pos : pos }],
516+
meta : [{ name : ":forward", params : [], pos : pos },{ name : ":fromNull", params : [], pos : pos }],
517517
kind : TDAbstract(tguid,null,[tguid],[tguid]),
518518
fields : fields,
519519
});

cdb/Types.hx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ abstract Guid<T>(String) {
467467

468468
public function toInt() : GuidInt<T> {
469469
if( this == null )
470-
return GuidInt.getNull();
470+
return #if haxe5 null #else GuidInt.getNull() #end;
471471
var k = 0;
472472
var tot = haxe.Int64.ofInt(0);
473473
for( i in 0...13 ) {
@@ -480,7 +480,7 @@ abstract Guid<T>(String) {
480480
}
481481

482482
public static function ofInt<T>( v : GuidInt<T> ) {
483-
if( v.isNull() )
483+
if( #if haxe5 v == null #else v.isNull() #end )
484484
return new Guid<T>(null);
485485
var str = "";
486486
var v : haxe.Int64 = v;
@@ -498,24 +498,19 @@ abstract Guid<T>(String) {
498498

499499
typedef GuidIntImpl = #if (hl && hl_ver >= version("1.16.0")) hl.GUID #else haxe.Int64 #end;
500500

501+
@:fromNull
501502
abstract GuidInt<T>(GuidIntImpl) from GuidIntImpl to GuidIntImpl {
502503

503504
public inline function toGuid() {
504505
return Guid.ofInt(this);
505506
}
506507

508+
#if !haxe5
507509
public inline function isNull() {
508510
return haxe.Int64.isZero(this);
509511
}
510-
511-
/*
512-
Disable until https://github.com/HaxeFoundation/haxe/issues/12422 is resolved
513-
public inline function setNull() {
514-
this = getNull();
515-
}
516-
*/
517-
518512
public static inline function getNull<T>() : GuidInt<T> return haxe.Int64.ofInt(0);
513+
#end
519514
}
520515

521516
class Index<T> {

0 commit comments

Comments
 (0)