You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So far, Error, Object and non-flat Enum have all grown instanceOf methods.
This ticket is to generate instanceOf methods for all types:
add a instanceOf(obj: any): obj is T to FfiConverter.
for types with existing instanceOf methods, the converter should call that type's static methods.
for object, the FfiConverter takes a factory which is generated. This should have the instanceOf method.
for primitive types, these can be hard coded e.g. typeof v === 'number'.
for Record, an structural types, we can implement the FfiConverter.instanceOf in terms of other FfiConverter.instanceOf methods, recursively calling instanceOf until a false is found.
Add instanceOf to the decl_type_name objects: mostly, I think for Record, but there may be others.
Consider a record:
typeMyRecord={name: string,age: /*uint8/number;};constMyRecord={create(value: {…}): MyRecord{…},instanceOf(obj: any): obj is MyRecord{returnFfiConverterTypeMyRecord.instanceOf(obj);},};
then, in the FfiConverterTypeMyRecord an instanceOf method can be implemented:
instanceOf(obj: any): obj is T{return(FfiConverterString.instanceOf(obj.name)&&FfiConverterUInt8.instanceOf(obj.age)&&);}
The text was updated successfully, but these errors were encountered:
So far,
Error
,Object
and non-flatEnum
have all growninstanceOf
methods.This ticket is to generate instanceOf methods for all types:
instanceOf(obj: any): obj is T
toFfiConverter
.instanceOf
methods, the converter should call that type's static methods.FfiConverter
takes afactory
which is generated. This should have theinstanceOf
method.typeof v === 'number'
.Record
, an structural types, we can implement theFfiConverter.instanceOf
in terms of otherFfiConverter.instanceOf
methods, recursively calling instanceOf until afalse
is found.instanceOf
to thedecl_type_name
objects: mostly, I think forRecord
, but there may be others.Consider a record:
then, in the
FfiConverterTypeMyRecord
aninstanceOf
method can be implemented:The text was updated successfully, but these errors were encountered: