X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=src%2Fcontext.h;h=dc350fbf6d19bd1814f76d769fbf1b3fa4cbc0f6;hp=d1322569999d5b6b6b234db11a43d2d39763cd35;hb=9bcb1df0786a8193d65949c857baaba2f4296e84;hpb=5e240548ba570610ce0dbc248a2b7654a0e080fa diff --git a/src/context.h b/src/context.h index d132256..dc350fb 100644 --- a/src/context.h +++ b/src/context.h @@ -1,17 +1,54 @@ -#ifndef _PSI_CONTEXT_H -#define _PSI_CONTEXT_H +/******************************************************************************* + Copyright (c) 2016, Michael Wallner . + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*******************************************************************************/ + +#ifndef PSI_CONTEXT_H +#define PSI_CONTEXT_H + +/* zend_function_entry */ +#include "Zend/zend_API.h" struct psi_context; struct psi_token; struct psi_parser; -struct decl_callinfo; +struct psi_call_frame; struct impl_vararg; +struct psi_decl; +struct psi_impl; + +enum psi_context_query { + PSI_CONTEXT_QUERY_SELF, /* ffi/jit */ + PSI_CONTEXT_QUERY_TYPE, /* impl type token_t to native ffi_type/jit_type */ +}; struct psi_context_ops { void (*init)(struct psi_context *C); void (*dtor)(struct psi_context *C); zend_function_entry *(*compile)(struct psi_context *C); - void (*call)(struct psi_context *C, struct decl_callinfo *decl_call, struct impl_vararg *va); + void (*call)(struct psi_context *C, struct psi_call_frame *frame, struct psi_decl *psi_decl, void *rval, void **args); + void (*call_va)(struct psi_context *C, struct psi_call_frame *frame, struct psi_decl *psi_decl, void *rval, void **args, size_t va_count, void **va_types); + void *(*query)(struct psi_context *C, enum psi_context_query q, void *arg); }; #include "data.h" @@ -25,12 +62,19 @@ struct psi_context { size_t count; }; +struct psi_context_call_data { + struct psi_context *context; + union { + struct psi_impl *fn; + struct psi_let_callback *cb; + } impl; +}; + struct psi_context *psi_context_init(struct psi_context *C, struct psi_context_ops *ops, psi_error_cb error, unsigned flags); void psi_context_build(struct psi_context *C, const char *path); -int psi_context_validate(struct psi_context *C, struct psi_parser *P); -int psi_context_validate_data(struct psi_data *C, struct psi_data *D); +bool psi_context_add_data(struct psi_context *C, struct psi_data *P); zend_function_entry *psi_context_compile(struct psi_context *C); -void psi_context_call(struct psi_context *C, struct decl_callinfo *decl_call, struct impl_vararg *va); +ZEND_RESULT_CODE psi_context_call(struct psi_context *C, zend_execute_data *execute_data, zval *return_value, struct psi_impl *impl); void psi_context_dump(struct psi_context *C, int fd); void psi_context_dtor(struct psi_context *C); void psi_context_free(struct psi_context **C);