He wrote it!
FUNCTION ClipArea() GEOM AS
in Riivo's code.
Riivo has used a custom function rather than a join in response to your question about GeomMakeRect (a built-in function).
Using a custom function rather than a join might be significantly faster in this case. It would be interesting to see a comparison.
The query can be simplified a bit, as Adam says, but it should work as it is for points, lines or areas, or any combination of object types.