All Downloads are FREE. Search and download functionalities are using the official Maven repository.

template.interface_c.txt Maven / Gradle / Ivy

There is a newer version: 2.0.5
Show newest version
/* Source generated by codegenj (https://github.com/olir/codegenj) - DO NOT EDIT!
 *
 * This generated output is free and unencumbered software released into the public domain.
 *
 * Anyone is free to copy, modify, publish, use, compile, sell, or
 * distribute this software, either in source code form or as a compiled
 * binary, for any purpose, commercial or non-commercial, and by any
 * means.
 * 
 * In jurisdictions that recognize copyright laws, the author or authors
 * of this software dedicate any and all copyright interest in the
 * software to the public domain. We make this dedication for the benefit
 * of the public at large and to the detriment of our heirs and
 * successors. We intend this dedication to be an overt act of
 * relinquishment in perpetuity of all present and future rights to this
 * software under copyright law.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 * 
 * For more information, please refer to 
 */
 
#include 
#include 
#include "$$$interface.jname$$$.h"
#include "$$$library$$$-codegen.h"

struct NativeReferenceStructure;

typedef struct NativeReferenceStructure { 
  GObject *value;
} NativeReference;

JNIEXPORT void JNICALL Java_$$$interface.jname$$$__1init(JNIEnv *env, jobject thisObj) {
	/*
    jclass _cls = (*env)->GetObjectClass(env, thisObj);
    jfieldID _fid = (*env)->GetFieldID(env, _cls, "_proxy", "Ljava/lang/Object;");
    jobject _bb = (*env)->GetObjectField(env, thisObj, _fid);
    NativeReference *_nref = (NativeReference*) (*env)->GetDirectBufferAddress(env, _bb);
    $$$interface.uname$$$ *_proxy = ($$$interface.uname$$$ *)_nref->value;
    
    ...
    */
}
 
JNIEXPORT void JNICALL Java_$$$interface.jname$$$__1destroy(JNIEnv *env, jobject thisObj) {
    jclass _cls = (*env)->GetObjectClass(env, thisObj);
    jfieldID _fid = (*env)->GetFieldID(env, _cls, "_proxy", "Ljava/lang/Object;");
    jobject _bb = (*env)->GetObjectField(env, thisObj, _fid);
    NativeReference *_nref = (NativeReference*) (*env)->GetDirectBufferAddress(env, _bb);
    $$$interface.uname$$$ *_proxy = ($$$interface.uname$$$ *)_nref->value;    
    free(_nref);

    g_object_unref(_proxy);
}

###for properties###
###case read###
	// getter for $$$property.name$$$ of type $$$property.type$$$
JNIEXPORT $$$method.jnireturntype$$$ JNICALL Java_$$$interface.jname$$$_$$$method.jname$$$(JNIEnv *env, jobject thisObj) {
    jclass _cls = (*env)->GetObjectClass(env, thisObj);
    jfieldID _fid = (*env)->GetFieldID(env, _cls, "_proxy", "Ljava/lang/Object;");
    jobject _bb = (*env)->GetObjectField(env, thisObj, _fid);
    NativeReference *_nref = (NativeReference*) (*env)->GetDirectBufferAddress(env, _bb);
    $$$interface.uname$$$ *_proxy = ($$$interface.uname$$$ *)_nref->value;    
	if (_proxy==NULL) {
		g_print("\nProxy not found!?\n");
	} 
	$$$method.cargmapcode$$$$$$interface.cname$$$_get_$$$method.cname$$$(_proxy);
$$$method.creturncode$$$}
###end###
###case write###
	// setter for $$$property.name$$$ of type $$$property.type$$$
JNIEXPORT void JNICALL Java_$$$interface.jname$$$_$$$method.jname$$$(JNIEnv *env, jobject thisObj$$$method.jniargs$$$) {
    jclass _cls = (*env)->GetObjectClass(env, thisObj);
    jfieldID _fid = (*env)->GetFieldID(env, _cls, "_proxy", "Ljava/lang/Object;");
    jobject _bb = (*env)->GetObjectField(env, thisObj, _fid);
    NativeReference *_nref = (NativeReference*) (*env)->GetDirectBufferAddress(env, _bb);
    $$$interface.uname$$$ *_proxy = ($$$interface.uname$$$ *)_nref->value;    
	if (_proxy==NULL) {
		g_print("\nProxy not found!?\n");
	} 
	$$$method.cargmapcode$$$$$$interface.cname$$$_set_$$$method.cname$$$(_proxy, c_arg_value);
}
###end###
###end###
 
###for method###
// Implementation of $$$interface.name$$$.$$$method.name$$$()
JNIEXPORT $$$method.jnireturntype$$$ JNICALL Java_$$$interface.jname$$$_$$$method.jname$$$(JNIEnv *env, jobject thisObj$$$method.jniargs$$$) {
    jclass _cls = (*env)->GetObjectClass(env, thisObj);
    jfieldID _fid = (*env)->GetFieldID(env, _cls, "_proxy", "Ljava/lang/Object;");
    jobject _bb = (*env)->GetObjectField(env, thisObj, _fid);
    NativeReference *_nref = (NativeReference*) (*env)->GetDirectBufferAddress(env, _bb);
    $$$interface.uname$$$ *_proxy = ($$$interface.uname$$$ *)_nref->value;    
	if (_proxy==NULL) {
		g_print("\nProxy not found!?\n");
	}
	else {
 		g_print("calling $$$interface.name$$$.$$$method.name$$$(...) on proxy of type %s\n", g_type_name (G_OBJECT_TYPE(_proxy)));
 	} 
    GError *_error = NULL;    
    $$$method.cargmapcode$$$gboolean _success = $$$interface.cname$$$_call_$$$method.cname$$$_sync(
        _proxy,
        $$$method.cparams$$$NULL,
        &_error
    );
    if (!_success) {
	    if (_error != NULL) {
		   jclass _eClass = (*env)->FindClass(env, "java/io/IOException");
	       (*env)->ThrowNew(env, _eClass, _error->message);
		   (*env)->DeleteLocalRef(env, _eClass);	      
	       g_error_free(_error);
	    }
	    else {
//			g_print("\nlibrary call failed. No error object set.\n");
		   jclass _eClass = (*env)->FindClass(env, "java/io/IOException");
	       (*env)->ThrowNew(env, _eClass, "Execution failed. Maybe not supported on current $$$interface.uname$$$ instance.");
		   (*env)->DeleteLocalRef(env, _eClass);
		}	      
    }
$$$method.cleanupcode$$$$$$method.creturncode$$$}
###end###




© 2015 - 2025 Weber Informatics LLC | Privacy Policy