Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Commit 01a541d

Browse files
committed
geometry compiler: count(list): bug #48
1 parent fff5fab commit 01a541d

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

libcurv/builtin.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,15 @@ struct Count_Function : public Legacy_Function
446446
}
447447
throw Exception(At_Arg(*this, args), "not a list or string");
448448
}
449+
GL_Value gl_call(GL_Frame& f) const override
450+
{
451+
auto arg = f[0];
452+
if (!arg.type.is_list())
453+
throw Exception(At_GL_Arg(0, f), "count: argument is not a list");
454+
auto result = f.gl.newvalue(GL_Type::Num());
455+
f.gl.out << " float "<<result<<" = "<<arg.type.count()<<";\n";
456+
return result;
457+
}
449458
};
450459
struct Fields_Function : public Legacy_Function
451460
{

libcurv/gl_type.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,9 @@ struct GL_Type
8888
// first dimension, if type is a list
8989
inline unsigned count() const
9090
{
91-
if (base_type_ >= Base_Type::Vec2)
92-
return base_info().dim1;
93-
else
91+
if (rank_)
9492
return dim1_;
93+
return base_info().dim1;
9594
}
9695
// If this is an array, strip one dimension off of the type.
9796
GL_Type abase()

0 commit comments

Comments
 (0)