File: cbc.xs

package info (click to toggle)
libconvert-binary-c-perl 0.74-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 9,100 kB
  • ctags: 21,416
  • sloc: ansic: 63,666; perl: 18,582; yacc: 2,143; makefile: 44
file content (89 lines) | stat: -rw-r--r-- 2,359 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
################################################################################
#
# $Project: /Convert-Binary-C $
# $Author: mhx $
# $Date: 2009/03/15 04:10:44 +0100 $
# $Revision: 12 $
# $Source: /xsubs/cbc.xs $
#
################################################################################
#
# Copyright (c) 2002-2009 Marcus Holland-Moritz. All rights reserved.
# This program is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
#
################################################################################


################################################################################
#
#   CONSTRUCTOR
#
#   WRITTEN BY: Marcus Holland-Moritz             ON: Jan 2002
#   CHANGED BY:                                   ON:
#
################################################################################

void
CBC::new(...)
  PREINIT:
    CBC_METHOD(new);

  PPCODE:
    CT_DEBUG_METHOD;

    if (items % 2 == 0)
      Perl_croak(aTHX_ "Number of configuration arguments "
                       "to %s must be even", method);
    else
    {
      int i;
      CBC *THIS = cbc_new(aTHX);

      if (gs_DisableParser)
      {
        Perl_warn(aTHX_ XSCLASS " parser is DISABLED");
        THIS->cfg.disable_parser = 1;
      }

      /* Only preset the option here, user may explicitly */
      /* disable OrderMembers in the constructor          */
      if (gs_OrderMembers)
        THIS->order_members = 1;

      /*
       *  bless the new object here, because handle_option()
       *  may croak and DESTROY would not be called to free
       *  the memory that has been allocated
       */
      ST(0) = sv_2mortal(cbc_bless(aTHX_ THIS, CLASS));

      for (i = 1; i < items; i += 2)
        handle_option(aTHX_ THIS, ST(i), ST(i+1), NULL, NULL);

      if (gs_OrderMembers && THIS->order_members)
        load_indexed_hash_module(aTHX_ THIS);

      XSRETURN(1);
    }


################################################################################
#
#   DESTRUCTOR
#
#   WRITTEN BY: Marcus Holland-Moritz             ON: Jan 2002
#   CHANGED BY:                                   ON:
#
################################################################################

void
CBC::DESTROY()
  PREINIT:
    CBC_METHOD(DESTROY);

  CODE:
    CT_DEBUG_METHOD;

    cbc_delete(aTHX_ THIS);