You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2009/10/19 00:00:54 UTC
svn commit: r826537 - in /lucene/lucy/trunk/perl/xs: XSBind.c XSBind.h
Author: marvin
Date: Sun Oct 18 22:00:53 2009
New Revision: 826537
URL: http://svn.apache.org/viewvc?rev=826537&view=rev
Log:
Add ByteBuf and the core numerical classes to the routines for converting
between Lucy-space and Perl-space in XSBind. Quiet a compiler warning with a
cast.
Modified:
lucene/lucy/trunk/perl/xs/XSBind.c
lucene/lucy/trunk/perl/xs/XSBind.h
Modified: lucene/lucy/trunk/perl/xs/XSBind.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/perl/xs/XSBind.c?rev=826537&r1=826536&r2=826537&view=diff
==============================================================================
--- lucene/lucy/trunk/perl/xs/XSBind.c (original)
+++ lucene/lucy/trunk/perl/xs/XSBind.c Sun Oct 18 22:00:53 2009
@@ -124,12 +124,30 @@
else if (Lucy_Obj_Is_A(obj, LUCY_CHARBUF)) {
return XSBind_cb_to_sv((lucy_CharBuf*)obj);
}
+ else if (Lucy_Obj_Is_A(obj, LUCY_BYTEBUF)) {
+ return XSBind_bb_to_sv((lucy_ByteBuf*)obj);
+ }
else if (Lucy_Obj_Is_A(obj, LUCY_VARRAY)) {
return S_lucy_array_to_perl_array((lucy_VArray*)obj);
}
else if (Lucy_Obj_Is_A(obj, LUCY_HASH)) {
return S_lucy_hash_to_perl_hash((lucy_Hash*)obj);
}
+ else if (Lucy_Obj_Is_A(obj, LUCY_FLOATNUM)) {
+ return newSVnv(Lucy_Num_To_F64(obj));
+ }
+ else if (sizeof(IV) == 8 && Lucy_Obj_Is_A(obj, LUCY_INTNUM)) {
+ chy_i64_t num = Lucy_Num_To_I64(obj);
+ return newSViv((IV)num);
+ }
+ else if (sizeof(IV) == 4 && Lucy_Obj_Is_A(obj, LUCY_INTEGER32)) {
+ chy_i32_t num = (chy_i32_t)Lucy_Num_To_I64(obj);
+ return newSViv((IV)num);
+ }
+ else if (sizeof(IV) == 4 && Lucy_Obj_Is_A(obj, LUCY_INTEGER64)) {
+ chy_i64_t num = Lucy_Num_To_I64(obj);
+ return newSVnv((double)num); /* lossy */
+ }
else {
return (SV*)Lucy_Obj_To_Host(obj);
}
@@ -181,6 +199,14 @@
}
SV*
+XSBind_bb_to_sv(const lucy_ByteBuf *bb)
+{
+ return bb
+ ? newSVpvn(Lucy_BB_Get_Buf(bb), Lucy_BB_Get_Size(bb))
+ : newSV(0);
+}
+
+SV*
XSBind_cb_to_sv(const lucy_CharBuf *cb)
{
if (!cb) {
@@ -367,7 +393,7 @@
for (i = num_stack_elems; i >= start + 2; i -= 2) {
chy_i32_t tick = i - 2;
SV *const key_sv = stack[tick];
- if (SvCUR(key_sv) == label_len) {
+ if (SvCUR(key_sv) == (STRLEN)label_len) {
if (memcmp(SvPVX(key_sv), label, label_len) == 0) {
*target = stack[tick + 1];
args_left--;
Modified: lucene/lucy/trunk/perl/xs/XSBind.h
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/perl/xs/XSBind.h?rev=826537&r1=826536&r2=826537&view=diff
==============================================================================
--- lucene/lucy/trunk/perl/xs/XSBind.h (original)
+++ lucene/lucy/trunk/perl/xs/XSBind.h Sun Oct 18 22:00:53 2009
@@ -6,9 +6,11 @@
#include "charmony.h"
#include "Lucy/Object/Obj.h"
+#include "Lucy/Object/ByteBuf.h"
#include "Lucy/Object/CharBuf.h"
#include "Lucy/Object/Err.h"
#include "Lucy/Object/Hash.h"
+#include "Lucy/Object/Num.h"
#include "Lucy/Object/VArray.h"
#include "Lucy/Object/VTable.h"
@@ -106,6 +108,11 @@
lucy_Obj*
lucy_XSBind_perl_to_lucy(SV *sv);
+/** Convert a ByteBuf into a new string SV.
+ */
+SV*
+lucy_XSBind_bb_to_sv(const lucy_ByteBuf *bb);
+
/** Convert a CharBuf into a new UTF-8 string SV.
*/
SV*
@@ -156,6 +163,7 @@
#define XSBind_lucy_obj_to_sv_noinc lucy_XSBind_lucy_obj_to_sv_noinc
#define XSBind_lucy_to_perl lucy_XSBind_lucy_to_perl
#define XSBind_perl_to_lucy lucy_XSBind_perl_to_lucy
+#define XSBind_bb_to_sv lucy_XSBind_bb_to_sv
#define XSBind_cb_to_sv lucy_XSBind_cb_to_sv
#define XSBind_enable_overload lucy_XSBind_enable_overload
#define XSBind_allot_params lucy_XSBind_allot_params