EIF_BOOLEAN c_is_valid_feature(char *type_name, char *feat_name) { void *ef; EIF_TYPE_ID eti; ef = NULL; eti = eif_type_id(type_name); if (eti != EIF_NO_TYPE) ef = eif_procedure(feat_name, eti); return (ef != NULL); }
int main (int argc,char **argv,char **envp) { EIF_INTEGER *c_array; int i, j; EIF_PROCEDURE p_make; /* `make ' from MY_ARRAY [INTEGER] */ EIF_PROCEDURE p_put; /* `put' from MY_ARRAY [INTEGER] */ EIF_PROCEDURE p_display; /* `display' from MY_ARRAY [INTEGER] */ EIF_TYPE_ID my_array_tid; /* MY_ARRAY [INTEGER] type id */ EIF_OBJECT o_array; /* Protected indirection to an array of integers */ EIF_INITIALIZE (failure) /* Initialization of Eiffel run-time */ /* Enable visible exception: raised whenever `eif_procedure' * returns a NULL pointer. * Note: not necessary, since it is set by default */ eif_enable_visible_exception (); /* Set Type id. */ /* `eif_type_id has been extended to generic type since v4.3 */ my_array_tid = eif_type_id ("MY_ARRAY[INTEGER]"); if (my_array_tid == EIF_NO_TYPE) /* MY_ARRAY's type id not found. */ eif_panic ("No type id."); /* Set procedures. */ p_make = eif_procedure ("make", my_array_tid); p_display = eif_procedure ("display", my_array_tid); p_put = eif_procedure ("put", my_array_tid); /* o_array is a protected indirection * it has to be accessed with `eif_access' * and freed with `eif_wean' */ o_array = eif_create (my_array_tid); /* Call `make (1, 10)' on new array */ (p_make) (eif_access (o_array), 1, 10); printf ("Enter 10 integers:\n"); c_array = (EIF_INTEGER *) malloc (10*sizeof (EIF_INTEGER)); /* Set C array */ for (i = 0; i < 10; i++) { printf ("Enter element %d: ", i + 1); scanf ("%d", &j); c_array [i] = (EIF_INTEGER) j; } printf ("\n"); /* Set Eiffel array from C array */ for (i = 0; i < 10; i++) { /* Call `put (value, i)' on array */ (p_put) (eif_access (o_array), (EIF_INTEGER) c_array [i], i+1); } (p_display) (eif_access (o_array)); /* Call `display on array */ eif_wean (o_array); /* Reclaim protected indirection so that the GC can * collect it */ EIF_DISPOSE_ALL /* Reclaim all objects allocated by Eiffel run-time. */ return 0; }
/* * Assumes type_name includes generic parameters if any. The full generic * type name can be generated using ANY.generating_type */ EIF_BOOLEAN c_is_class_visible(char *type_name) { return (eif_type_id(type_name) != EIF_NO_TYPE); }
/* * create an object by name and call its make routine with a single argument * which must be a reference object */ EIF_REFERENCE c_create_make_object(char *type_name, char *make_proc_name, EIF_REFERENCE make_arg) { return c_create_make_object_by_id(eif_type_id(type_name), make_proc_name, make_arg); }
EIF_INTEGER c_eif_type_id(char *type_name) { return (eif_type_id(type_name)); }
EIF_RT_BASIC_CLEANUP } void failure_function () { } JNIEXPORT void JNICALL Java_com_eiffel_EiffelActivity_sendCreateActivity(JNIEnv *env, jobject obj, jobject activity, jstring name, jobject bundle){ EIF_PROCEDURE ep; EIF_TYPE_ID controller_id; if (eiffel_android_controller==NULL){ int argc = 0; char **argv = NULL; char **envp = NULL; EIF_INITIALIZE(failure_function) } EIF_TYPE_ID application_id; EIF_PROCEDURE emake, einit; application_id = eif_type_id ("ANDROID_APPLICATION"); if (application_id == EIF_NO_TYPE){ eif_panic ("No ANDROID_APPLICATION class!"); } eiffel_android_controller = eif_create(application_id); emake = eif_procedure ("make", application_id); (emake) (eif_access (eiffel_android_controller)); einit = eif_procedure ("initialize_jvm", application_id); (einit) (eif_access (eiffel_android_controller), env); } controller_id = eif_type_id ("ANDROID_CONTROLLER"); ep = eif_procedure ("receive_create_activity", controller_id); (ep) (eif_access (eiffel_android_controller), env, activity, name, bundle); } JNIEXPORT void JNICALL Java_com_eiffel_EiffelActivity_sendDestroyActivity(JNIEnv *env, jobject object, jobject activity, jstring name){ EIF_PROCEDURE receive_destroy_activity;