void set_byte_continuation(struct thread *thread, obj_t component) { int n_const = COMPONENT(component)->n_constants; thread->component = component; thread->pc = (char *)(&COMPONENT(component)->constant[n_const]) - (char *)component; thread->sp = thread->fp + COMPONENT(component)->frame_size; #ifdef MINDY_SLOW_FUNCTION_POINTERS thread->advance = NULL; #else thread->advance = interpret_next_byte; #endif }
static void push_function(struct thread *thread, int arg) { struct variable *var = (struct variable *)COMPONENT(thread->component)->constant[arg]; obj_t value = var->value; switch (var->function) { case func_No: type_error(value, obj_FunctionClass); case func_Yes: case func_Always: break; case func_Maybe: if (instancep(value, obj_FunctionClass)) { var->function = func_Yes; break; } else if (value == obj_Unbound) error("Unbound variable: %s", var->name); else { var->function = func_No; type_error(value, obj_FunctionClass); } } *thread->sp++ = value; }
static void push_value(struct thread *thread, int arg) { struct variable *var = (struct variable *)COMPONENT(thread->component)->constant[arg]; obj_t value = var->value; if (value != obj_Unbound) *thread->sp++ = value; else error("Unbound variable: %s", var->name); }
static void pop_value(struct thread *thread, int arg) { struct variable *var = (struct variable *)COMPONENT(thread->component)->constant[arg]; obj_t value = *--thread->sp; if (var->type != obj_False && !instancep(value, var->type)) type_error(value, var->type); if (var->function != func_Always) var->function = func_Maybe; var->value = value; }
obj_t make_component(obj_t debug_name, int frame_size, obj_t mtime, obj_t source_file, obj_t debug_info, int nconst, int nbytes) { int len = sizeof(struct component) + sizeof(obj_t)*(nconst - 1) + nbytes; obj_t res = alloc(obj_ComponentClass, len); int i; COMPONENT(res)->length = len; COMPONENT(res)->debug_name = debug_name; COMPONENT(res)->frame_size = frame_size; COMPONENT(res)->mtime = mtime; COMPONENT(res)->source_file = source_file; COMPONENT(res)->debug_info = debug_info; COMPONENT(res)->n_constants = nconst; for (i = 0; i < nconst; i++) COMPONENT(res)->constant[i] = obj_Unbound; return res; }
//---------------------------------------------------------------------- //---------------------------------------------------------------------- int main(int argc, char *argv[]) { char *component = argv[0]; /* * This shows how to add an optional output to logging. A printer * to stdout is the default (logcat on Android). There can be any * number of output channels. This one uses as SQLite database. * */ tj_log_outchannel *chan; if ((chan = tj_log_sqlite_create(0)) == 0) { TJ_LOG_CRITICAL(component, "Could not create sqlite outchannel."); return -1; } tj_log_addOutChannel(chan); /* * TODO: Ability to remove channels (i.e., the default). * TODO: Component filters and remapping. */ TJ_LOG_VERBOSE(component, "This is a verbose output."); TJ_LOG_LOGIC(component, "This is a logic output: Result is %d.", 4); // Use the shorthand form. COMPONENT("This is a component output with string '%s'.", "mushi"); // Use the shorthand form. CRITICAL("This is a critical error output."); tj_error *err = tj_error_create(TJ_ERROR_MISSING_SERVICE, "Bad mojo!"); TJ_LOG_ERROR(component, err, "This is a critical error output with an error."); return 0; // end main }
World() : SystemBase("World", {}, {COMPONENT(BodyComponent)}), m_map(320, 320) {}
static obj_t trans_component(obj_t component) { return transport(component, COMPONENT(component)->length, true); }
static void push_constant(struct thread *thread, int arg) { *thread->sp++ = COMPONENT(thread->component)->constant[arg]; }
* either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsXPCOM.h" #include "nsIGenericFactory.h" #include "nsFileSpecImpl.h" #define COMPONENT(NAME, Ctor) \ { NS_##NAME##_CLASSNAME, NS_##NAME##_CID, NS_##NAME##_CONTRACTID, Ctor } static const nsModuleComponentInfo components[] = { COMPONENT(FILESPEC, nsFileSpecImpl::Create), COMPONENT(DIRECTORYITERATOR, nsDirectoryIteratorImpl::Create), }; NS_IMPL_NSGETMODULE(xpcomObsoleteModule, components)
* of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsXPCOM.h" #include "nsIGenericFactory.h" #include "nsFileSpecImpl.h" #include "nsRegistry.h" #define COMPONENT(NAME, Ctor) \ { NS_##NAME##_CLASSNAME, NS_##NAME##_CID, NS_##NAME##_CONTRACTID, Ctor } NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegistry) static const nsModuleComponentInfo components[] = { COMPONENT(FILESPEC, nsFileSpecImpl::Create), COMPONENT(DIRECTORYITERATOR, nsDirectoryIteratorImpl::Create), COMPONENT(REGISTRY, nsRegistryConstructor), }; NS_IMPL_NSGETMODULE(xpcomObsoleteModule, components)