ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/cfperl.xs
(Generate patch)

Comparing deliantra/server/server/cfperl.xs (file contents):
Revision 1.245 by root, Thu Aug 30 05:24:14 2007 UTC vs.
Revision 1.246 by root, Thu Aug 30 07:28:25 2007 UTC

99 *stash_cf_arch_wrap, 99 *stash_cf_arch_wrap,
100 *stash_cf_party_wrap, 100 *stash_cf_party_wrap,
101 *stash_cf_region_wrap, 101 *stash_cf_region_wrap,
102 *stash_cf_living_wrap; 102 *stash_cf_living_wrap;
103 103
104static inline SV *
105newSVpv_utf8 (const char *s)
106{
107 SV *sv = newSVpv (s, 0);
108 SvUTF8_on (sv);
109 return sv;
110}
111
112static inline SV *
113newSVpvn_utf8 (const char *s, STRLEN l)
114{
115 SV *sv = newSVpvn (s, l);
116 SvUTF8_on (sv);
117 return sv;
118}
119
104// helper cast function, returns super class * or 0 120// helper cast function, returns super class * or 0
105template<class super> 121template<class super>
106static super * 122static super *
107is_a (attachable *at) 123is_a (attachable *at)
108{ 124{
247 } 263 }
248 } 264 }
249} 265}
250 266
251void 267void
252attachable::set_key (const char *key, const char *value) 268attachable::set_key (const char *key, const char *value, bool is_utf8)
253{ 269{
254 if (!self) 270 if (!self)
255 self = newHV (); 271 self = newHV ();
256 272
257 if (value) 273 if (value)
258 hv_store (self, key, strlen (key), newSVpv (value, 0), 0); 274 hv_store (self, key, strlen (key), is_utf8 ? newSVpv_utf8 (value) : newSVpv (value, 0), 0);
259 else 275 else
260 hv_delete (self, key, strlen (key), G_DISCARD); 276 hv_delete (self, key, strlen (key), G_DISCARD);
261} 277}
262 278
263attachable & 279attachable &
394{ 410{
395 if (SvOK (sv)) 411 if (SvOK (sv))
396 return SvPTR (sv, klass); 412 return SvPTR (sv, klass);
397 else 413 else
398 return 0; 414 return 0;
399}
400
401static inline SV *
402newSVpv_utf8 (const char *s)
403{
404 SV *sv = newSVpv (s, 0);
405 SvUTF8_on (sv);
406 return sv;
407}
408
409static inline SV *
410newSVpvn_utf8 (const char *s, STRLEN l)
411{
412 SV *sv = newSVpvn (s, l);
413 SvUTF8_on (sv);
414 return sv;
415} 415}
416 416
417inline SV *to_sv (const shstr & v) { return v ? newSVpvn_utf8 ((const char *)v, v.length ()) : &PL_sv_undef; } 417inline SV *to_sv (const shstr & v) { return v ? newSVpvn_utf8 ((const char *)v, v.length ()) : &PL_sv_undef; }
418inline SV *to_sv (const char * v) { return newSVpv (v, 0); } 418inline SV *to_sv (const char * v) { return newSVpv (v, 0); }
419inline SV *to_sv (bool v) { return newSViv (v); } 419inline SV *to_sv (bool v) { return newSViv (v); }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines