#include #include #include #include "../src/mlp_priv.h" #include "mlp_java_priv.h" void *_mlp_java_new_object(mlp_context *ctx, const mlp_class *class_, int nb_args, const mlp_value **args){ JavaVM *jvm = mlp_context_get_runtime(ctx)->runtime ; JNIEnv *env = mlp_java_get_env(jvm) ; /* We need jvalue *jargs = (jvalue *)malloc(nb_args *) jclass jcls = class_ int i = 0 ; for (i = 0 ; i < nb_args ; i++){ SV *sv = mlp_perl_make_SV(ctx, args[i]) ; if (mlp_context_has_error(ctx)){ return NULL ; } XPUSHs(sv) ; } PUTBACK ; int count = call_method("new", G_SCALAR | G_EVAL) ; SPAGAIN ; if (SvTRUE(ERRSV)){ STRLEN n_a ; mlp_context_set_error(ctx, MLP_NO_SUCH_FUNCTION, "Error creating Perl object: %s", SvPV(ERRSV, n_a)) ; return NULL ; } else if (count != 1){ mlp_context_set_error(ctx, MLP_INVALID_RETURN_VALUE, "Perl function must return 1 value (not %d)", count) ; return NULL ; } obj = newRV_inc(SvRV(POPs)) ; mlp_debug(5, "refcnt=%d", SvREFCNT(obj)) ; FREETMPS ; LEAVE ; return obj ; */ return NULL ; } mlp_value *_mlp_java_call_method(mlp_context *ctx, const mlp_object *object, const char *name, int nb_args, const mlp_value **args, mlp_type return_type){ /* PerlInterpreter *my_perl = mlp_context_get_runtime(ctx)->runtime ; mlp_value *ret = NULL ; dSP ; ENTER ; SAVETMPS ; PUSHMARK(SP) ; XPUSHs((SV *)object->object) ; int i = 0 ; for (i = 0 ; i < nb_args ; i++){ SV *sv = mlp_perl_make_SV(ctx, args[i]) ; if (mlp_context_has_error(ctx)){ return NULL ; } XPUSHs(sv) ; } PUTBACK ; int count = call_method(name, G_SCALAR | G_EVAL) ; SPAGAIN ; if (SvTRUE(ERRSV)){ STRLEN n_a ; mlp_context_set_error(ctx, MLP_NO_SUCH_FUNCTION, "Error calling method %s: %s", name, SvPV(ERRSV, n_a)) ; return NULL ; } else if (count != 1){ mlp_context_set_error(ctx, MLP_INVALID_RETURN_VALUE, "Perl method must return 1 value (not %d)", count) ; return NULL ; } STRLEN n_a ; ret = mlp_new_string_value(ctx, POPpx) ; mlp_debug_value(ret, "perl ret") ; FREETMPS ; LEAVE ; return ret ; */ return NULL ; } void _mlp_java_detach_object(mlp_context *ctx, const mlp_object *object){ //PerlInterpreter *my_perl = mlp_context_get_runtime(ctx)->runtime ; //SvREFCNT_dec((SV *)object->object) ; } void _mlp_java_delete_object(mlp_context *ctx, const mlp_object *object){ //_mlp_perl_detach_object(ctx, object) ; }