~ubuntu-branches/ubuntu/jaunty/libglib-perl/jaunty

« back to all changes in this revision

Viewing changes to GError.xs

  • Committer: Bazaar Package Importer
  • Author(s): Marc 'HE' Brockschmidt
  • Date: 2008-03-15 09:40:14 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20080315094014-af0fqrtad5fq1u0f
Tags: 1:1.181-1
New upstream release (only changes in the build system irrelevant for
Debian, but for completeness' sake...)

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 * along with this library; if not, write to the Free Software Foundation,
17
17
 * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307  USA.
18
18
 *
19
 
 * $Header: /cvsroot/gtk2-perl/gtk2-perl-xs/Glib/GError.xs,v 1.11 2006/07/23 10:20:59 kaffeetisch Exp $
 
19
 * $Header: /cvsroot/gtk2-perl/gtk2-perl-xs/Glib/GError.xs,v 1.15 2008/01/07 19:17:08 kaffeetisch Exp $
20
20
 */
21
21
 
22
22
#include "gperl.h"
219
219
         * side effect, 0 is also allowed.  we just won't advertise that.
220
220
         * the logic here is a bit ugly to avoid running the overloaded
221
221
         * stringification operator via SvTRUE(). */
222
 
        if (!sv || !SvOK (sv) || /* not defined */
223
 
            (!SvROK (sv) && !SvTRUE (sv))) { /* not a ref, but still false */
 
222
        if (!gperl_sv_is_defined (sv) ||                /* not defined */
 
223
            (!SvROK (sv) && !SvTRUE (sv)))      /* not a ref, but still false */
 
224
        {
224
225
                *error = NULL;
225
226
                return;
226
227
        }
228
229
        /*
229
230
         * now we must parse a hash.
230
231
         */
231
 
        if (!SvROK (sv) || SvTYPE (SvRV (sv)) != SVt_PVHV)
 
232
        if (!gperl_sv_is_hash_ref (sv))
232
233
                croak ("expecting undef or a hash reference for a GError");
233
234
 
234
235
        /*
243
244
                const char * domain;
244
245
                GQuark qdomain;
245
246
                svp = hv_fetch (hv, "domain", 6, FALSE);
246
 
                if (!svp || !SvOK (sv))
 
247
                if (!svp || !gperl_sv_is_defined (*svp))
247
248
                        g_error ("key 'domain' not found in plain hash for GError");
248
249
                domain = SvPV_nolen (*svp);
249
250
                qdomain = g_quark_try_string (domain);
262
263
         * error code.  prefer the 'value' key, fall back to 'code'.
263
264
         */
264
265
        svp = hv_fetch (hv, "value", 5, FALSE);
265
 
        if (svp && SvOK (*svp))
 
266
        if (svp && gperl_sv_is_defined (*svp))
266
267
                scratch.code = gperl_convert_enum (info->error_enum, *svp);
267
268
        else {
268
269
                svp = hv_fetch (hv, "code", 4, FALSE);
269
 
                if (!svp || !SvOK (*svp))
 
270
                if (!svp || !gperl_sv_is_defined (*svp))
270
271
                        croak ("error hash contains neither a 'value' nor 'code' key; no error valid error code found");
271
272
                scratch.code = SvIV (*svp);
272
273
        }
275
276
         * the message is the easy part.
276
277
         */
277
278
        svp = hv_fetch (hv, "message", 7, FALSE);
278
 
        if (!svp || !SvOK (*svp))
 
279
        if (!svp || !gperl_sv_is_defined (*svp))
279
280
                croak ("error has contains no error message");
280
281
        scratch.message = SvGChar (*svp);
281
282