2 Copyright (C) 2008-2009, Parrot Foundation.
7 src/pmc/sockaddr.pmc - sockaddr_in holder
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.
32 /* HEADERIZER HFILE: none */
33 /* HEADERIZER BEGIN: static */
34 /* HEADERIZER END: static */
36 pmclass Sockaddr auto_attrs {
37 ATTR void *pointer; /* The stored pointer. */
43 Initializes the pointer object.
50 Parrot_Sockaddr_attributes * const pdata_struct =
51 (Parrot_Sockaddr_attributes *) PMC_data(SELF);
53 pdata_struct->pointer = mem_gc_allocate_zeroed_typed(INTERP,
55 PObj_custom_destroy_SET(SELF);
60 =item C<void destroy()>
62 Destroys the PMC and frees all allocated memory.
68 VTABLE void destroy() {
69 Parrot_Sockaddr_attributes * const data = PARROT_SOCKADDR(SELF);
72 mem_gc_free(INTERP, data->pointer);
81 Creates and returns a clone of the pointer.
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));
96 =item C<void *get_pointer()>
104 VTABLE void *get_pointer() {
105 Parrot_Sockaddr_attributes * const data = PARROT_SOCKADDR(SELF);
106 return data->pointer;
111 =item C<void set_pointer(void *)>
120 VTABLE void set_pointer(void *value) {
121 Parrot_Sockaddr_attributes * const data = PARROT_SOCKADDR(SELF);
122 return data->pointer;
138 * c-file-style: "parrot"
140 * vim: expandtab shiftwidth=4: