… | |
… | |
15 | /*struct coro;*/ /* opaque */ |
15 | /*struct coro;*/ /* opaque */ |
16 | |
16 | |
17 | /* private structure, always use the provided macros below */ |
17 | /* private structure, always use the provided macros below */ |
18 | struct CoroAPI { |
18 | struct CoroAPI { |
19 | I32 ver; |
19 | I32 ver; |
|
|
20 | I32 rev; |
20 | #define CORO_API_VERSION 5 |
21 | #define CORO_API_VERSION 6 |
21 | #define CORO_API_REVISION 0 |
22 | #define CORO_API_REVISION 0 |
22 | |
23 | |
23 | /* internal */ |
24 | /* internal */ |
24 | /*struct coro *(*sv_to_coro)(SV *arg, const char *funcname, const char *varname);*/ |
25 | /*struct coro *(*sv_to_coro)(SV *arg, const char *funcname, const char *varname);*/ |
25 | |
26 | |
… | |
… | |
32 | int (*cede_notself) (void); |
33 | int (*cede_notself) (void); |
33 | int (*ready) (SV *coro_sv); |
34 | int (*ready) (SV *coro_sv); |
34 | int (*is_ready) (SV *coro_sv); |
35 | int (*is_ready) (SV *coro_sv); |
35 | int *nready; |
36 | int *nready; |
36 | SV *current; |
37 | SV *current; |
|
|
38 | |
|
|
39 | SV *(*coro_event_next)(SV *watcher, int cancel, int wantev); |
37 | }; |
40 | }; |
38 | |
41 | |
39 | static struct CoroAPI *GCoroAPI; |
42 | static struct CoroAPI *GCoroAPI; |
40 | |
43 | |
41 | /* public API macros */ |
44 | /* public API macros */ |
… | |
… | |
51 | #define I_CORO_API(YourName) \ |
54 | #define I_CORO_API(YourName) \ |
52 | STMT_START { \ |
55 | STMT_START { \ |
53 | SV *sv = perl_get_sv("Coro::API",0); \ |
56 | SV *sv = perl_get_sv("Coro::API",0); \ |
54 | if (!sv) croak("Coro::API not found"); \ |
57 | if (!sv) croak("Coro::API not found"); \ |
55 | GCoroAPI = (struct CoroAPI*) SvIV(sv); \ |
58 | GCoroAPI = (struct CoroAPI*) SvIV(sv); \ |
56 | if (GCoroAPI->ver != CORO_API_VERSION) { \ |
59 | if (GCoroAPI->ver != CORO_API_VERSION) \ |
57 | croak("Coro::API version mismatch (%d != %d) -- please recompile %s", \ |
60 | croak("Coro::API version mismatch (%d != %d) -- please recompile %s", \ |
58 | GCoroAPI->ver, CORO_API_VERSION, YourName); \ |
61 | GCoroAPI->ver, CORO_API_VERSION, YourName); \ |
59 | } \ |
62 | if (GCoroAPI->rev < CORO_API_REVISION) \ |
|
|
63 | croak("Coro::API revision outdated (%d != %d) -- please recompile %s", \ |
|
|
64 | GCoroAPI->rev, CORO_API_REVISION, YourName); \ |
60 | } STMT_END |
65 | } STMT_END |
61 | |
66 | |
62 | #endif |
67 | #endif |
63 | |
68 | |