view src/parallel_execution/examples/helloWorld/HelloImpl.cbc @ 971:edbd4495f08f

add helloWorld
author matac42 <matac@cr.ie.u-ryukyu.ac.jp>
date Thu, 17 Jun 2021 21:01:20 +0900
parents
children 6a9ad3da2daf
line wrap: on
line source

#include "../../../context.h"
#include <stdio.h>
#impl "Hello.h" as "HelloImpl.h"
#interface "Hello.h"

// ----
// typedef struct HelloImpl <> impl Hello {
//   char* hString;
//   char* wString;
// } HelloImpl;
// ----

Hello* createHelloImpl(struct Context* context) {
    struct Hello* hello  = new Hello();
    struct HelloImpl* hello_impl = new HelloImpl();
    hello->hello = (union Data*)hello_impl;
    hello->string = NULL;
    hello_impl->hString = NULL;
    hello_impl->wString = NULL;
    hello->h = C_hHelloImpl;
    hello->w = C_wHelloImpl;
    return hello;
}
__code h(struct HelloImpl* hello, __code next(...)) {
    hello->string = "Hello, ";
    printf("%s", hello->string);
    goto w(hello, next);
}

__code w(struct HelloImpl* hello, __code next(...)) {
    // printf("%s", hello_impl->wString);
    goto next(...);
}