Clownfish-CFC
view release on metacpan or search on metacpan
* [CLOWNFISH-84] - Guarantee nul-terminated arg to strtod in Str_To_F64
Improvements:
* [CLOWNFISH-7] - String-only keys for Hash
* [CLOWNFISH-11] - Rework ByteBuf
* [CLOWNFISH-15] - Method OFFSET vars should be uint32_t instead of
size_t
* [CLOWNFISH-27] - Use functions rather than methods for refcounting
* [CLOWNFISH-29] - Use PERL_NO_GET_CONTEXT
* [CLOWNFISH-30] - Eliminate autogenerated "callbacks.h"
* [CLOWNFISH-34] - String-only keys for LFReg
* [CLOWNFISH-35] - Use size_t for Array and Hash indices
* [CLOWNFISH-39] - Public Vector API
* [CLOWNFISH-40] - LockFreeRegistry should be private
* [CLOWNFISH-42] - Move NumberUtils to Lucy
* [CLOWNFISH-49] - Remove Obj_Mimic, Obj_To_[FI]64, Obj_To_Bool
* [CLOWNFISH-50] - Convert some Obj methods to inert functions
* [CLOWNFISH-51] - Go glue should convert clownfish.String to Go string
* [CLOWNFISH-52] - Implement To_Host methods for core types
* [CLOWNFISH-53] - Support MSVC in C mode
src/CFCBindClass.c view on Meta::CPAN
S_inert_var_declarations(CFCBindClass *self);
// Define type-safe wrappers for Obj functions.
static char*
S_wrapper_defs(CFCBindClass *self);
// Define method invocation inline functions.
static char*
S_method_defs(CFCBindClass *self);
// Declare override symbols for functions which wrap host callbacks.
static char*
S_override_decs(CFCBindClass *self);
// Define short names for all of the symbols associated with this class.
static char*
S_short_names(CFCBindClass *self);
static const CFCMeta CFCBINDCLASS_META = {
"Clownfish::CFC::Binding::Core::Class",
sizeof(CFCBindClass),
src/CFCBindClass.c view on Meta::CPAN
"/* Define type-safe wrappers for inert functions of Obj.\n"
" */\n"
"\n"
"%s\n"
"\n"
"/* Define the inline functions which implement this class's virtual methods.\n"
" */\n"
"\n"
"%s\n"
"\n"
"/* Declare callbacks for wrapping host overrides.\n"
" */\n"
"\n"
"%s\n"
"\n"
"/* Define \"short names\" for this class's symbols.\n"
" */\n"
"\n"
"%s\n"
"\n";
char *content
src/CFCPython.c view on Meta::CPAN
const char *inc_dest = CFCHierarchy_get_include_dest(self->hierarchy);
char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "cfish_hostdefs.h",
inc_dest);
CFCUtil_write_if_changed(filepath, content, strlen(content));
FREEMEM(filepath);
FREEMEM(content);
}
static char*
S_gen_callbacks(CFCPython *self, CFCParcel *parcel, CFCClass **ordered) {
CHY_UNUSED_VAR(self);
CHY_UNUSED_VAR(parcel);
char *callbacks = CFCUtil_strdup("");
// Generate implementation files containing callback definitions.
for (size_t i = 0; ordered[i] != NULL; i++) {
CFCClass *klass = ordered[i];
if (CFCClass_included(klass)
|| CFCClass_inert(klass)
//|| CFCClass_get_parcel(klass) != parcel
) {
continue;
}
CFCMethod **fresh_methods = CFCClass_fresh_methods(klass);
for (int meth_num = 0; fresh_methods[meth_num] != NULL; meth_num++) {
CFCMethod *method = fresh_methods[meth_num];
// Define callback.
if (CFCMethod_novel(method) && !CFCMethod_final(method)) {
char *cb_def = CFCPyMethod_callback_def(method, klass);
callbacks = CFCUtil_cat(callbacks, cb_def, "\n", NULL);
FREEMEM(cb_def);
}
}
}
static const char helpers[] =
"static PyObject*\n"
"S_pack_tuple(int num_args, ...) {\n"
" PyObject *tuple = PyTuple_New(num_args);\n"
" va_list args;\n"
src/CFCPython.c view on Meta::CPAN
" Py_DECREF(py_result);\n"
" return result;\n"
"}\n"
;
static const char pattern[] =
"%s\n"
"\n"
"%s"
;
char *content = CFCUtil_sprintf(pattern, helpers, callbacks);
FREEMEM(callbacks);
return content;
}
static char*
S_gen_type_linkups(CFCPython *self, CFCParcel *parcel, CFCClass **ordered) {
CHY_UNUSED_VAR(self);
CHY_UNUSED_VAR(parcel);
char *handles = CFCUtil_strdup("");
char *py_types = CFCUtil_strdup("");
int num_items = 0;
src/CFCPython.c view on Meta::CPAN
? last_dot + 1
: pymod_name;
char *helper_mod_name = CFCUtil_sprintf("%s._%s", pymod_name, last_component);
for (int i = 0; helper_mod_name[i] != '\0'; i++) {
helper_mod_name[i] = CFCUtil_tolower(helper_mod_name[i]);
}
CFCClass **ordered = CFCHierarchy_ordered_classes(self->hierarchy);
CFCParcel **parcels = CFCParcel_all_parcels();
char *privacy_syms = CFCUtil_strdup("");
char *callbacks = S_gen_callbacks(self, parcel, ordered);
char *type_linkups = S_gen_type_linkups(self, parcel, ordered);
char *pound_includes = CFCUtil_strdup("");
char *class_bindings = S_gen_class_bindings(self, parcel, pymod_name, ordered);
char *parcel_boots = CFCUtil_strdup("");
char *pytype_ready_calls = CFCUtil_strdup("");
char *module_adds = CFCUtil_strdup("");
// Add privacy defines and parcel bootstrapping calls.
for (size_t i = 0; parcels[i]; ++i) {
if (!CFCParcel_included(parcels[i])) {
src/CFCPython.c view on Meta::CPAN
const char pattern[] =
"%s\n"
"\n"
"%s"
"\n"
"#include \"Python.h\"\n"
"#include \"cfish_parcel.h\"\n"
"#include \"CFBind.h\"\n"
"%s\n"
"\n"
"%s\n" // callbacks
"\n"
"static PyModuleDef module_def = {\n"
" PyModuleDef_HEAD_INIT,\n"
" \"%s\",\n" // module name
" NULL,\n" // docstring
" -1,\n"
" NULL, NULL, NULL, NULL, NULL\n"
"};\n"
"\n"
"%s" // class bindings
src/CFCPython.c view on Meta::CPAN
"%s\n" // Add types to module
"\n"
" return module;\n"
"}\n"
"\n"
"%s\n"
"\n";
char *content
= CFCUtil_sprintf(pattern, self->header, privacy_syms, pound_includes,
callbacks, helper_mod_name, class_bindings,
type_linkups, last_component, pytype_ready_calls,
parcel_boots, module_adds, self->footer);
char *filepath = CFCUtil_sprintf("%s" CHY_DIR_SEP "_%s.c", dest,
last_component);
CFCUtil_write_if_changed(filepath, content, strlen(content));
FREEMEM(filepath);
FREEMEM(content);
FREEMEM(module_adds);
FREEMEM(pytype_ready_calls);
FREEMEM(parcel_boots);
FREEMEM(class_bindings);
FREEMEM(helper_mod_name);
FREEMEM(pymod_name);
FREEMEM(pound_includes);
FREEMEM(type_linkups);
FREEMEM(callbacks);
FREEMEM(privacy_syms);
FREEMEM(ordered);
}
void
CFCPython_write_bindings(CFCPython *self, const char *parcel_name, const char *dest) {
CFCParcel *parcel = CFCParcel_fetch(parcel_name);
if (parcel == NULL) {
CFCUtil_die("Unknown parcel: %s", parcel_name);
}
( run in 1.104 second using v1.01-cache-2.11-cpan-9b1e4054eb1 )