add native function isa(object,class)

This commit is contained in:
ValKmjolnir
2022-04-05 22:33:55 +08:00
parent 8b7e0e5181
commit 28ca3baf87
3 changed files with 43 additions and 2 deletions
+12
View File
@@ -236,6 +236,8 @@ var isvec=func(v){
return typeof(v)=="vec";
}
# get the index of val in the vec
var vecindex=func(vec,val){
forindex(var i;vec)
if(val==vec[i])
@@ -243,6 +245,16 @@ var vecindex=func(vec,val){
return nil;
}
# check if the object is an instance of the class
var isa=func(object,class){
if(!contains(object,"parents") or typeof(object.parents)!="vec")
return 0;
foreach(var elem;object.parents)
if(elem==class)
return 1;
return 0;
}
var io=
{
SEEK_SET:0,