CamlIDL and string options.

From: David Brown (caml-list@davidb.org)
Date: Wed Feb 23 2000 - 18:54:25 MET

  • Next message: skaller: "Re:"

    I'm trying to write a camlidl interface for a function that returns a
    char *. I want the ML result to be a string option. If the returned
    pointer is null, then return None, otherwise return the string it
    points to in Some.

    I can make it work, but only by writing my own c2ml routine:

    value field_to_ml (one_field *_c2, camlidl_ctx _ctx)
    {
      value _v1;
      value _v3;
      if ((*_c2) == NULL) {
        _v1 = Val_int(0);
      } else {
        _v3 = copy_string (*_c2);
        Begin_root(_v3)
          _v1 = camlidl_alloc_small(1, 0);
          Field(_v1, 0) = _v3;
        End_roots();
      }
      return _v1;
    }

    Ideally, I would like to be able to use another field to get the
    length, but that function needs another argument that the interface
    function gets as an argument.

    --------------------------------------------------
    In actuality, the function is more complicated than even this. It
    actually returns a char**. There is a function available that returns
    the number of char*'s in it. There is another function that returns
    the length of each char* (provided they aren't NULL).

    The other possibility is that someone else has already written an
    interface of MySQL, and I'm duplicating their effort.

    Dave Brown



    This archive was generated by hypermail 2b29 : Wed Feb 23 2000 - 18:57:50 MET