Skip to content

Commit 3bca564

Browse files
committed
use hl.GUID (hl-ver 1.16+)
1 parent d4cd076 commit 3bca564

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

cdb/Types.hx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,9 @@ abstract Guid<T>(String) {
496496
static var CVALUES = [for( i in 0...128 ) CHARS.indexOf(String.fromCharCode(i))];
497497
}
498498

499-
abstract GuidInt<T>(haxe.Int64) from haxe.Int64 to haxe.Int64 {
499+
typedef GuidIntImpl = #if (hl && hl_ver >= version("1.16.0")) hl.GUID #else haxe.Int64 #end;
500+
501+
abstract GuidInt<T>(GuidIntImpl) from GuidIntImpl to GuidIntImpl {
500502

501503
public inline function toGuid() {
502504
return Guid.ofInt(this);
@@ -673,14 +675,32 @@ class IndexGuid<T,Kind> extends IndexId<T,Kind> {
673675
override function initSheet(data:Data) {
674676
super.initSheet(data);
675677
byGUID = new GuidMap();
678+
#if hl
679+
var idCol = null;
680+
for( c in sheet.columns ) {
681+
switch( c.type ) {
682+
case TId: idCol = c; break;
683+
default:
684+
}
685+
}
686+
#end
676687
for( c in sheet.columns )
677688
switch( c.type ) {
678689
case TGuid:
679690
var cname = c.name;
680691
for( a in sheet.lines ) {
681692
var id : Guid<T> = Reflect.field(a, cname);
682-
if( id != null && id != cast "" )
683-
byGUID.set(id.toInt(), a);
693+
if( id != null && id != cast "" ) {
694+
var iid = id.toInt();
695+
byGUID.set(iid, a);
696+
#if (hl && hl_ver >= version("1.16.0"))
697+
if( idCol != null ) {
698+
var id = Reflect.field(a,idCol.name);
699+
if( id != null && id != "" )
700+
hl.Api.registerGUIDName(iid,id);
701+
}
702+
#end
703+
}
684704
}
685705
break;
686706
default:

0 commit comments

Comments
 (0)