Simplify contract macros.

This commit is contained in:
Christoffer Lerno
2025-06-02 22:53:01 +02:00
parent a48e2274e5
commit 8fc01d4e1a

View File

@@ -148,15 +148,13 @@ macro bool is_array_or_slice_of_char(bytes)
{
$switch @typekind(bytes):
$case POINTER:
var $Inner = $typefrom($typeof(bytes).inner);
$if $Inner.kindof == ARRAY:
var $Inner2 = $typefrom($Inner.inner);
return $Inner2.typeid == char.typeid;
typeid $inner = $typeof(bytes).inner;
$if $inner.kindof == ARRAY:
return $inner.inner == char.typeid;
$endif
$case ARRAY:
$case SLICE:
var $Inner = $typefrom($typeof(bytes).inner);
return $Inner.typeid == char.typeid;
return $typeof(bytes).inner == char.typeid;
$default:
return false;
$endswitch
@@ -166,14 +164,12 @@ macro bool is_arrayptr_or_slice_of_char(bytes)
{
$switch @typekind(bytes):
$case POINTER:
var $Inner = $typefrom($typeof(bytes).inner);
$if $Inner.kindof == ARRAY:
var $Inner2 = $typefrom($Inner.inner);
return $Inner2.typeid == char.typeid;
var $inner = $typeof(bytes).inner;
$if $inner.kindof == ARRAY:
return $inner.inner == char.typeid;
$endif
$case SLICE:
var $Inner = $typefrom($typeof(bytes).inner);
return $Inner.typeid == char.typeid;
return $typeof(bytes).inner == char.typeid;
$default:
return false;
$endswitch