#line 39 "t/src/extend_vtable.t"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "parrot/embed.h"
#include "parrot/extend.h"
#include "parrot/extend_vtable.h"

static void fail(const char *msg);
static Parrot_String createstring(Parrot_Interp interp, const char * value);
static Parrot_Interp new_interp();

static void fail(const char *msg)
{
    fprintf(stderr, "failed: %s\n", msg);
    exit(EXIT_FAILURE);
}

static Parrot_String createstring(Parrot_Interp interp, const char * value)
{
    return Parrot_new_string(interp, value, strlen(value), (const char*)NULL, 0);
}

static Parrot_Interp new_interp()
{
    Parrot_Interp interp = Parrot_new(NULL);
    if (!interp)
        fail("Cannot create parrot interpreter");
    return interp;

}

#line 77 "t/src/extend_vtable.t"
int main(void)
{
    Parrot_Interp interp;
    Parrot_PMC pmc, pmc2, pmc3, pmc_string, pmc_string2;
    Parrot_PMC pmc_float, pmc_float2;
    Parrot_PMC rpa, rpa2;
    Parrot_Int type, value, integer, integer2;
    Parrot_Float number, number2;
    Parrot_String string, string2;

    interp = new_interp();

    type   = Parrot_PMC_typenum(interp, "Integer");
    rpa    = Parrot_PMC_new(interp, Parrot_PMC_typenum(interp, "ResizablePMCArray"));
    rpa2   = Parrot_PMC_new(interp, Parrot_PMC_typenum(interp, "ResizablePMCArray"));
    pmc    = Parrot_PMC_new(interp, type);
    pmc2   = Parrot_PMC_new(interp, type);
    pmc3   = Parrot_PMC_new(interp, type);

    pmc_string = Parrot_PMC_new(interp, Parrot_PMC_typenum(interp,"String"));
    pmc_string2 = Parrot_PMC_new(interp, Parrot_PMC_typenum(interp,"String"));

    pmc_float  = Parrot_PMC_new(interp, Parrot_PMC_typenum(interp,"Float"));
    pmc_float2 = Parrot_PMC_new(interp, Parrot_PMC_typenum(interp,"Float"));

    Parrot_PMC_set_integer_native(interp, pmc, 42);
    Parrot_PMC_set_integer_native(interp, pmc2, 99);

    Parrot_PMC_freeze(interp, pmc, pmc2);
    Parrot_PMC_thaw(interp, pmc, pmc2);
    Parrot_printf(interp,"%d\n", 42);


    /* TODO: Properly test this */
    Parrot_PMC_destroy(interp, pmc);

    Parrot_destroy(interp);
    printf("Done!\n");
    return 0;
}
