git.annexia.org
/
perl4caml.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
ebb3016
)
Added correct handling of undef.
author
rich
<rich>
Thu, 25 Nov 2004 22:16:17 +0000
(22:16 +0000)
committer
rich
<rich>
Thu, 25 Nov 2004 22:16:17 +0000
(22:16 +0000)
examples/test.ml
patch
|
blob
|
history
perl.ml
patch
|
blob
|
history
perl_c.c
patch
|
blob
|
history
diff --git
a/examples/test.ml
b/examples/test.ml
index
05d6042
..
490401e
100644
(file)
--- a/
examples/test.ml
+++ b/
examples/test.ml
@@
-1,6
+1,6
@@
(* Simple test of the API.
* Copyright (C) 2003 Merjis Ltd.
(* Simple test of the API.
* Copyright (C) 2003 Merjis Ltd.
- * $Id: test.ml,v 1.
6 2003-12-11 17:41:52
rich Exp $
+ * $Id: test.ml,v 1.
7 2004-11-25 22:16:17
rich Exp $
*)
open Printf
*)
open Printf
@@
-48,5
+48,10
@@
let () =
let sv = Perl.call_method obj "get_foo" [] in
printf "TestClass.foo is %d\n" (Perl.int_of_sv sv); flush stdout;
let sv = Perl.call_method obj "get_foo" [] in
printf "TestClass.foo is %d\n" (Perl.int_of_sv sv); flush stdout;
+ (* Create an undef value and test it. *)
+ let undef = Perl.sv_undef () in
+ printf "sv_is_undef (undef) = %s\n"
+ (string_of_bool (Perl.sv_is_undef undef));
+
(* Perform a full collection - good way to find GC/allocation bugs. *)
Gc.full_major ()
(* Perform a full collection - good way to find GC/allocation bugs. *)
Gc.full_major ()
diff --git
a/perl.ml
b/perl.ml
index
a193446
..
cdbfa7c
100644
(file)
--- a/
perl.ml
+++ b/
perl.ml
@@
-1,6
+1,6
@@
(* Interface to Perl from OCaml.
* Copyright (C) 2003 Merjis Ltd.
(* Interface to Perl from OCaml.
* Copyright (C) 2003 Merjis Ltd.
- * $Id: perl.ml,v 1.1
1 2003-12-11 17:41:52
rich Exp $
+ * $Id: perl.ml,v 1.1
2 2004-11-25 22:16:17
rich Exp $
*)
type sv
*)
type sv
@@
-26,6
+26,7
@@
external string_of_sv : sv -> string = "perl4caml_string_of_sv"
external sv_of_string : string -> sv = "perl4caml_sv_of_string"
external sv_is_true : sv -> bool = "perl4caml_sv_is_true"
external sv_undef : unit -> sv = "perl4caml_sv_undef"
external sv_of_string : string -> sv = "perl4caml_sv_of_string"
external sv_is_true : sv -> bool = "perl4caml_sv_is_true"
external sv_undef : unit -> sv = "perl4caml_sv_undef"
+external sv_is_undef : sv -> bool = "perl4caml_sv_is_undef"
external sv_yes : unit -> sv = "perl4caml_sv_yes"
external sv_no : unit -> sv = "perl4caml_sv_no"
external sv_yes : unit -> sv = "perl4caml_sv_yes"
external sv_no : unit -> sv = "perl4caml_sv_no"
@@
-47,8
+48,6
@@
type sv_t = SVt_NULL
| SVt_PVMG
external sv_type : sv -> sv_t = "perl4caml_sv_type"
| SVt_PVMG
external sv_type : sv -> sv_t = "perl4caml_sv_type"
-let sv_is_undef sv =
- SVt_NULL = sv_type sv
let string_of_sv_t = function
SVt_NULL -> "SVt_NULL"
let string_of_sv_t = function
SVt_NULL -> "SVt_NULL"
diff --git
a/perl_c.c
b/perl_c.c
index
f11a2b5
..
4241534
100644
(file)
--- a/
perl_c.c
+++ b/
perl_c.c
@@
-1,6
+1,6
@@
/* Interface to Perl from OCaml.
* Copyright (C) 2003 Merjis Ltd.
/* Interface to Perl from OCaml.
* Copyright (C) 2003 Merjis Ltd.
- * $Id: perl_c.c,v 1.1
6 2004-11-03 14:15:18
rich Exp $
+ * $Id: perl_c.c,v 1.1
7 2004-11-25 22:16:17
rich Exp $
*/
#include <stdio.h>
*/
#include <stdio.h>
@@
-158,7
+158,17
@@
CAMLprim value
perl4caml_sv_undef (value unit)
{
CAMLparam1 (unit);
perl4caml_sv_undef (value unit)
{
CAMLparam1 (unit);
- CAMLreturn (Val_sv (newSV (0)));
+ /*CAMLreturn (Val_sv (newSV (0)));*/
+ CAMLreturn (Val_sv (&PL_sv_undef));
+}
+
+CAMLprim value
+perl4caml_sv_is_undef (value svv)
+{
+ CAMLparam1 (svv);
+ SV *sv = Sv_val (svv);
+ CAMLreturn (!SvPOK (sv) && !SvIOK (sv) && SvTYPE (sv) == SVt_NULL
+ ? Val_true : Val_false);
}
CAMLprim value
}
CAMLprim value