fix codetest failure - ASSERT_ARGS does not have a ; after and
[parrot.git] / src / pmc / sockaddr.pmc
blob616155782e41389b8e9e9358f89b864da3aab25b
1 /*
2 Copyright (C) 2008-2009, Parrot Foundation.
3 $Id$
5 =head1 NAME
7 src/pmc/sockaddr.pmc - sockaddr_in holder
9 =head1 DESCRIPTION
11 The Sockaddr PMC holds raw c-pointer to sockaddr_in
14 =head2 Vtable Functions
16 These are the vtable functions for the Sockaddr class.
18 =over 4
20 =cut
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27     struct sockaddr_in;
28 #ifdef __cplusplus
30 #endif
32 /* HEADERIZER HFILE: none */
33 /* HEADERIZER BEGIN: static */
34 /* HEADERIZER END: static */
36 pmclass Sockaddr auto_attrs {
37     ATTR void   *pointer; /* The stored pointer. */
41 =item C<void init()>
43 Initializes the pointer object.
45 =cut
49     VTABLE void init() {
50         Parrot_Sockaddr_attributes * const pdata_struct =
51             (Parrot_Sockaddr_attributes *) PMC_data(SELF);
53         pdata_struct->pointer = mem_gc_allocate_zeroed_typed(INTERP,
54                 struct sockaddr_in);
55         PObj_custom_destroy_SET(SELF);
56     }
60 =item C<void destroy()>
62 Destroys the PMC and frees all allocated memory.
64 =cut
68     VTABLE void destroy() {
69         Parrot_Sockaddr_attributes * const data = PARROT_SOCKADDR(SELF);
71         if (data) {
72             mem_gc_free(INTERP, data->pointer);
73             data->pointer = NULL;
74         }
75     }
79 =item C<PMC *clone()>
81 Creates and returns a clone of the pointer.
83 =cut
87     VTABLE PMC *clone() {
88         PMC * const dest = Parrot_pmc_new(INTERP, SELF->vtable->base_type);
89         memcpy(PARROT_SOCKADDR(dest)->pointer, PARROT_SOCKADDR(SELF)->pointer,
90                 sizeof (struct sockaddr_in));
91         return dest;
92     }
96 =item C<void *get_pointer()>
98 Returns the pointer.
100 =cut
104     VTABLE void *get_pointer() {
105         Parrot_Sockaddr_attributes * const data = PARROT_SOCKADDR(SELF);
106         return data->pointer;
107     }
111 =item C<void set_pointer(void *)>
113 Sets the pointer.
115 =cut
120     VTABLE void set_pointer(void *value) {
121         Parrot_Sockaddr_attributes * const data = PARROT_SOCKADDR(SELF);
122         return data->pointer;
123     }
130 =back
132 =cut
137  * Local variables:
138  *   c-file-style: "parrot"
139  * End:
140  * vim: expandtab shiftwidth=4:
141  */