[plt-scheme] Moving mzscheme extension to 299.XX

From: David J. Neu (djneu at att.net)
Date: Thu Feb 17 14:23:19 EST 2005

Hi,

I'm trying to move a mzscheme extension from 208 to 299.XX.

I changed all occurrences of:

   SCHEME_STRINGP => SCHEME_CHAR_STRINGP

and

   SCHEME_STR_VAL => SCHEME_CHAR_STR_VAL

This didn't work.  The problem is demonstrated in the code snippet
below.  For example

> (return-string "hello")
h
"hello"

So, the test SCHEME_CHAR_STRINGP succeeds, but calling
SCHEME_CHAR_STR_VAL to extract the string "hello" and sending the
result to a C function only yields the first char.

Any thoughts - it must be something obvious.

Thanks!

Cheers,
David


/*
  Create using:
  mzc --cc test.c
  mzc --ld test.so test.o
*/

#include "escheme.h"

Scheme_Object *sch_return_string(int aargc, Scheme_Object **aargv)
{
  if (!SCHEME_CHAR_STRINGP(aargv[0]))
    {
      scheme_wrong_type("return-string", "string", 0, aargc, aargv);
    }
  printf("%s\n", SCHEME_CHAR_STR_VAL(aargv[0]));
  return scheme_make_char_string(SCHEME_CHAR_STR_VAL(aargv[0]));
}

Scheme_Object *scheme_reload(Scheme_Env *env)
{
  Scheme_Object *proc;

  proc = scheme_make_prim_w_arity(sch_return_string, "return-string", 1, 1);
  scheme_add_global("return-string", proc, env);

  return scheme_void;
}

Scheme_Object *scheme_initialize(Scheme_Env *env)
{
  return scheme_reload(env);
}

Scheme_Object *scheme_module_name()
{
  return scheme_false;
}



Posted on the users mailing list.