Skip to content

Commit a47fde5

Browse files
committed
print and equal? support external types
1 parent 7231982 commit a47fde5

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

Diff for: lisp.c

+6
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,12 @@ bool St_EqualP(StObject lhs, StObject rhs)
295295
return St_VectorEqualP(lhs, rhs);
296296
}
297297

298+
if (ST_EXTERNALP(lhs) && ST_EXTERNALP(rhs) &&
299+
ST_EXTERNAL_TYPE_INFO(lhs) == ST_EXTERNAL_TYPE_INFO(rhs))
300+
{
301+
return ST_EXTERNAL_TYPE_INFO(lhs)->equalp(lhs, rhs);
302+
}
303+
298304
return St_EqvP(lhs, rhs);
299305
}
300306

Diff for: lisp.h

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct StExternalObjectHeader
5454
};
5555
typedef struct StExternalObjectHeader *StExternalObject;
5656
#define ST_EXTERNAL_OBJECT(x) ((StExternalObject)(x))
57+
#define ST_EXTERNAL_TYPE_INFO(x) (ST_EXTERNAL_OBJECT(x)->type_info)
5758

5859
struct StCellRec
5960
{

Diff for: print.c

+6
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ static void print(StObject obj, StObject port)
145145
break;
146146
}
147147

148+
case TEXTERNAL: {
149+
ST_EXTERNAL_TYPE_INFO(obj)->print(obj, port);
150+
151+
break;
152+
}
153+
148154
default:
149155
St_Error("unknown type %d", obj->type);
150156
}

0 commit comments

Comments
 (0)