view src/parallel_execution/examples/helloWorld/HelloImpl.cbc @ 1070:fba66b75a7dc default tip

rollback
author matac42 <matac@cr.ie.u-ryukyu.ac.jp>
date Mon, 05 Feb 2024 01:48:23 +0900
parents 793b21a8ea12
children
line wrap: on
line source

#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->hString = "Hello, "; //createImpl部分では_implなのだが動く
    printf("%s", hello->hString);
    goto w(hello, next);
}

__code w(struct HelloImpl* hello, __code next(...)) {
    hello->wString = "World.\n";
    printf("%s", hello->wString);
    goto next(...);
}