xo-interpreter2 stack: refactor: move cwd() -> ObjectPrimitives

This commit is contained in:
Roland Conybeare 2026-03-15 14:25:35 -05:00
commit 32b26d1163
3 changed files with 22 additions and 0 deletions

View file

@ -10,6 +10,7 @@
#include <xo/object2/Integer.hpp>
#include <xo/printable2/Printable.hpp>
#include <xo/stringtable2/String.hpp>
#include <unistd.h> // for getcwd()
namespace xo {
using xo::scm::ASequence;
@ -21,6 +22,23 @@ namespace xo {
namespace scm {
// ----- cwd -----
obj<AGCObject>
xfer_cwd(obj<ARuntimeContext> rcx)
{
char buf[PATH_MAX];
::getcwd(buf, sizeof(buf));
return obj<AGCObject,DString>(DString::from_cstr(rcx.allocator(), buf));
}
DPrimitive_gco_0 *
ObjectPrimitives::make_cwd_pm(obj<AAllocator> mm)
{
return DPrimitive_gco_0::_make(mm, "cwd", &xfer_cwd);
}
// ----- nth -----
// TODO: seq_gc -> obj<ASequence>