Revision: 1126
Author: [email protected]
Date: Mon Mar 8 01:48:41 2010
Log: Move attribute handling into a new function load_attribute_callback().
Convert the length argument of I32, so that it can store attributes with
UTF-8
keys. Not that we can do this yet, but it makes sense for the callback API
to
be future-proof.
http://code.google.com/p/perl-devel-nytprof/source/detail?r=1126
Modified:
/trunk/NYTProf.xs
=======================================
--- /trunk/NYTProf.xs Mon Mar 8 01:48:36 2010
+++ /trunk/NYTProf.xs Mon Mar 8 01:48:41 2010
@@ -34,6 +34,7 @@
#define NEED_newCONSTSUB
#define NEED_newRV_noinc
#define NEED_sv_2pv_flags
+#define NEED_newSVpvn_flags
# include "ppport.h"
#endif
@@ -3458,7 +3459,7 @@
static void
-store_attrib_sv(pTHX_ HV *attr_hv, const char *text, STRLEN text_len, SV
*value_sv)
+store_attrib_sv(pTHX_ HV *attr_hv, const char *text, I32 text_len, SV
*value_sv)
{
(void)hv_store(attr_hv, text, text_len, value_sv, 0);
if (trace_level >= 1)
@@ -3693,6 +3694,36 @@
newSVnv(state->profiler_duration));
}
+
+static void
+load_attribute_callback(Loader_state *state, ...)
+{
+ dTHXa(state->interp);
+ va_list args;
+ char *key;
+ unsigned long key_len;
+ unsigned int key_utf8;
+ char *value;
+ unsigned long value_len;
+ unsigned int value_utf8;
+
+ va_start(args, state);
+
+ key = va_arg(args, char *);
+ key_len = va_arg(args, unsigned long);
+ key_utf8 = va_arg(args, unsigned int);
+
+ value = va_arg(args, char *);
+ value_len = va_arg(args, unsigned long);
+ value_utf8 = va_arg(args, unsigned int);
+
+ va_end(args);
+
+ store_attrib_sv(aTHX_ state->attr_hv, key,
+ key_utf8 ? -(I32)key_len : key_len,
+ newSVpvn_flags(value, value_len,
+ value_utf8 ? SVf_UTF8 : 0));
+}
/**
* Process a profile output file and return the results in a hash like
@@ -4309,7 +4340,10 @@
call_sv(cb, G_DISCARD);
SPAGAIN;
} else {
- store_attrib_sv(aTHX_ state.attr_hv, buffer, key_end -
buffer, newSVpvn(value, end - value));
+ load_attribute_callback(&state, buffer,
+ (unsigned long)(key_end -
buffer),
+ 0, value,
+ (unsigned long)(end - value),
0);
}
if (memEQs(buffer, key_end - buffer, "ticks_per_sec")) {
ticks_per_sec = (unsigned int)atoi(value);
--
You've received this message because you are subscribed to
the Devel::NYTProf Development User group.
Group hosted at: http://groups.google.com/group/develnytprof-dev
Project hosted at: http://perl-devel-nytprof.googlecode.com
CPAN distribution: http://search.cpan.org/dist/Devel-NYTProf
To post, email: [email protected]
To unsubscribe, email: [email protected]