Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null safety project support #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions hxbit/Serializer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ class Serializer {
public inline function getArray<T>(f:Void->T) : Array<T> {
var len = getInt();
if( len == 0 )
#if hxbit_nullsafety
return [];
#else
return null;
#end
len--;
var a = [];
for( i in 0...len )
Expand All @@ -241,7 +245,11 @@ class Serializer {
public inline function getVector<T>(f:Void->T) : haxe.ds.Vector<T> {
var len = getInt();
if( len == 0 )
#if hxbit_nullsafety
return new haxe.ds.Vector<T>(0);
#else
return null;
#end
len--;
var a = new haxe.ds.Vector<T>(len);
for( i in 0...len )
Expand All @@ -265,7 +273,11 @@ class Serializer {
@:extern public inline function getMap<K,T>(fk:Void->K, ft:Void->T) : Map<K,T> {
var len = getInt();
if( len == 0 )
#if hxbit_nullsafety
return new Map<K,T>();
#else
return null;
#end
var m = new Map<K,T>();
while( --len > 0 ) {
var k = fk();
Expand Down Expand Up @@ -347,7 +359,11 @@ class Serializer {
public inline function getString() {
var len = getInt();
if( len == 0 )
#if hxbit_nullsafety
return "";
#else
return null;
#end
len--;
var s = input.getString(inPos, len);
inPos += len;
Expand All @@ -357,7 +373,11 @@ class Serializer {
public inline function getBytes() {
var len = getInt();
if( len == 0 )
#if hxbit_nullsafety
return haxe.io.Bytes.alloc(0);
#else
return null;
#end
len--;
var s = input.sub(inPos, len);
inPos += len;
Expand Down