/*
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
 */

#import "common.h"
#import "GlassMacros.h"

//#define VERBOSE
#ifndef VERBOSE
    #define LOG(MSG, ...)
#else
    #define LOG(MSG, ...) GLASS_LOG(MSG, ## __VA_ARGS__);
#endif

#pragma mark --- JNI

/*
 * Class:     com_sun_glass_ui_mac_MacGestureSupport
 * Method:    _initIDs
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_com_sun_glass_ui_mac_MacGestureSupport__1initIDs
(JNIEnv *env, jclass jClass)
{
    LOG("Java_com_sun_glass_ui_mac_MacGestureSupport__1initIDs");

    if (jGestureSupportClass == NULL)
    {
        jGestureSupportClass = (*env)->NewGlobalRef(env, jClass);
    }

    if (jGestureSupportRotateGesturePerformed == NULL)
    {
        jGestureSupportRotateGesturePerformed = 
                    (*env)->GetStaticMethodID(env, jGestureSupportClass, 
                                "rotateGesturePerformed",
                                "(Lcom/sun/glass/ui/View;IIIIIF)V");
        GLASS_CHECK_EXCEPTION(env);
    }

    if (jGestureSupportScrollGesturePerformed == NULL)
    {
        jGestureSupportScrollGesturePerformed = 
                    (*env)->GetStaticMethodID(env, jGestureSupportClass, 
                                "scrollGesturePerformed",
                                "(Lcom/sun/glass/ui/View;IIIIIFF)V");
        GLASS_CHECK_EXCEPTION(env);
    }

    if (jGestureSupportSwipeGesturePerformed == NULL)
    {
        jGestureSupportSwipeGesturePerformed = 
                    (*env)->GetStaticMethodID(env, jGestureSupportClass, 
                                "swipeGesturePerformed",
                                "(Lcom/sun/glass/ui/View;IIIIII)V");
        GLASS_CHECK_EXCEPTION(env);
    }

    if (jGestureSupportMagnifyGesturePerformed == NULL)
    {
        jGestureSupportMagnifyGesturePerformed = 
                    (*env)->GetStaticMethodID(env, jGestureSupportClass, 
                                "magnifyGesturePerformed",
                                "(Lcom/sun/glass/ui/View;IIIIIF)V");
        GLASS_CHECK_EXCEPTION(env);
    }

    if (jGestureSupportGestureFinished == NULL)
    {
        jGestureSupportGestureFinished = 
                    (*env)->GetStaticMethodID(env, jGestureSupportClass, 
                                "gestureFinished",
                                "(Lcom/sun/glass/ui/View;IIIII)V");
        GLASS_CHECK_EXCEPTION(env);
    }

    if (jGestureSupportNotifyBeginTouchEvent == NULL)
    {
        jGestureSupportNotifyBeginTouchEvent = 
                    (*env)->GetStaticMethodID(env, jGestureSupportClass, 
                                "notifyBeginTouchEvent",
                                "(Lcom/sun/glass/ui/View;II)V");
        GLASS_CHECK_EXCEPTION(env);
    }

    if (jGestureSupportNotifyNextTouchEvent == NULL)
    {
        jGestureSupportNotifyNextTouchEvent = 
                    (*env)->GetStaticMethodID(env, jGestureSupportClass, 
                                "notifyNextTouchEvent",
                                "(Lcom/sun/glass/ui/View;IJFF)V");
        GLASS_CHECK_EXCEPTION(env);
    }

    if (jGestureSupportNotifyEndTouchEvent == NULL)
    {
        jGestureSupportNotifyEndTouchEvent = 
                    (*env)->GetStaticMethodID(env, jGestureSupportClass, 
                                "notifyEndTouchEvent",
                                "(Lcom/sun/glass/ui/View;)V");
        GLASS_CHECK_EXCEPTION(env);
    }
}
