/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

// This file is autogenerated by
//     weex_core_debug/Source/WeexCore/platform/android/jniprebuild/jni_generator.py
// For
//     org/apache/weex/bridge/JsFunctions

#ifndef WEEX_PROJECT_WXJSFUNCTIONS_JNI_H
#define WEEX_PROJECT_WXJSFUNCTIONS_JNI_H

#include <jni.h>
#include "base/android/jni/android_jni.h"

namespace {
    const char kWXJsFunctionClassPath[] = "org/apache/weex/bridge/WXJsFunctions";
// Leaking this jclass as we cannot use LazyInstance from some threads.
    jclass g_WXJsFunction_clazz = NULL;
#define WXJsFunction_clazz(env) g_WXJsFunction_clazz

}  // namespace

static void initWxBridge(JNIEnv *env, jobject object, jobject bridge, jstring className);

static void jsHandleSetJSVersion(JNIEnv *env, jobject object, jstring jsVersion);

static void jsHandleReportException(JNIEnv *env, jobject object, jstring instanceId, jstring func,
                                    jstring exceptionjstring);

static void jsHandleCallNative(JNIEnv *env, jobject object, jstring instanceId, jbyteArray tasks,
                               jstring callback);

static void
jsHandleCallNativeModule(JNIEnv *env, jobject object, jstring instanceId, jstring module,
                         jstring method, jbyteArray
                         arguments, jbyteArray options,jboolean from);

static void
jsHandleCallNativeComponent(JNIEnv *env, jobject object, jstring instanceId, jstring componentRef,
                            jstring method,
                            jbyteArray arguments, jbyteArray options, jboolean from);

static void
jsHandleCallAddElement(JNIEnv *env, jobject object, jstring instanceId, jstring ref, jbyteArray dom,
                       jstring index);

static void jsHandleSetTimeout(JNIEnv *env, jobject object, jstring callbackId, jstring time);

static void jsHandleCallNativeLog(JNIEnv *env, jobject object, jbyteArray str_array);

static void jsFunctionCallCreateBody(JNIEnv *env, jobject object, jstring pageId, jbyteArray domStr, jboolean from);

static void
jsFunctionCallUpdateFinish(JNIEnv *env, jobject object, jstring instanceId, jbyteArray tasks,
                           jstring callback);

static void jsFunctionCallCreateFinish(JNIEnv *env, jobject object, jstring pageId);

static void
jsFunctionCallRefreshFinish(JNIEnv *env, jobject object, jstring instanceId, jbyteArray tasks,
                            jstring callback);

static void
jsFunctionCallUpdateAttrs(JNIEnv *env, jobject object, jstring pageId, jstring ref, jbyteArray data, jboolean from);

static void
jsFunctionCallUpdateStyle(JNIEnv *env, jobject object, jstring pageId, jstring ref, jbyteArray data, jboolean from);

static void jsFunctionCallRemoveElement(JNIEnv *env, jobject object, jstring pageId, jstring ref);

static void
jsFunctionCallMoveElement(JNIEnv *env, jobject object, jstring pageId, jstring ref,
                          jstring parentRef, jstring index_str);

static void
jsFunctionCallAddEvent(JNIEnv *env, jobject object, jstring pageId, jstring ref, jstring event);

static void
jsFunctionCallRemoveEvent(JNIEnv *env, jobject object, jstring pageId, jstring ref, jstring event);

static void jsHandleSetInterval(JNIEnv *env, jobject object, jstring instanceId, jstring callbackId,
                                jstring time);

static void
jsHandleClearInterval(JNIEnv *env, jobject object, jstring instanceId, jstring callbackId);

static void jsHandleCallGCanvasLinkNative(JNIEnv *env, jobject object, jstring contextId, int type,
                                          jstring val);


static const JNINativeMethod kMethodsWXJsFunctions[] = {
        {"initWxBridge",
                "(Ljava/lang/Object;Ljava/lang/String;)V",
                reinterpret_cast<void *>(initWxBridge)},
        {"jsHandleSetJSVersion",
                "(Ljava/lang/String;)V",
                reinterpret_cast<void *>(jsHandleSetJSVersion)},
        {"jsHandleReportException",
                "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
                reinterpret_cast<void *>(jsHandleReportException)},
        {"jsHandleCallNative",
                "(Ljava/lang/String;[BLjava/lang/String;)V",
                reinterpret_cast<void *>(jsHandleCallNative)},
        {"jsHandleCallNativeModule",
                "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[B[BZ)V",
                reinterpret_cast<void *>(jsHandleCallNativeModule)},
        {"jsHandleCallNativeComponent",
                "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[B[BZ)V",
                reinterpret_cast<void *>(jsHandleCallNativeComponent)},
        {"jsHandleCallAddElement",
                "(Ljava/lang/String;Ljava/lang/String;[BLjava/lang/String;Z)V",
                reinterpret_cast<void *>(jsHandleCallAddElement)},
        {"jsHandleSetTimeout",
                "(Ljava/lang/String;Ljava/lang/String;)V",
                reinterpret_cast<void *>(jsHandleSetTimeout)},
        {"jsHandleCallNativeLog",
                "([B)V",
                reinterpret_cast<void *>(jsHandleCallNativeLog)},
        {"jsFunctionCallCreateBody",
                "(Ljava/lang/String;[BZ)V",
                reinterpret_cast<void *>(jsFunctionCallCreateBody)},
        {"jsFunctionCallUpdateFinish",
                "(Ljava/lang/String;[BLjava/lang/String;)V",
                reinterpret_cast<void *>(jsFunctionCallUpdateFinish)},
        {"jsFunctionCallCreateFinish",
                "(Ljava/lang/String;)V",
                reinterpret_cast<void *>(jsFunctionCallCreateFinish)},
        {"jsFunctionCallRefreshFinish",
                "(Ljava/lang/String;[BLjava/lang/String;)V",
                reinterpret_cast<void *>(jsFunctionCallRefreshFinish)},
        {"jsFunctionCallUpdateAttrs",
                "(Ljava/lang/String;Ljava/lang/String;[BZ)V",
                reinterpret_cast<void *>(jsFunctionCallUpdateAttrs)},
        {"jsFunctionCallUpdateStyle",
                "(Ljava/lang/String;Ljava/lang/String;[BZ)V",
                reinterpret_cast<void *>(jsFunctionCallUpdateStyle)},
        {"jsFunctionCallRemoveElement",
                "(Ljava/lang/String;Ljava/lang/String;)V",
                reinterpret_cast<void *>(jsFunctionCallRemoveElement)},
        {"jsFunctionCallMoveElement",
                "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
                reinterpret_cast<void *>(jsFunctionCallMoveElement)},
        {"jsFunctionCallAddEvent",
                "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
                reinterpret_cast<void *>(jsFunctionCallAddEvent)},
        {"jsFunctionCallRemoveEvent",
                "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
                reinterpret_cast<void *>(jsFunctionCallRemoveEvent)},
        {"jsHandleSetInterval",
                "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
                reinterpret_cast<void *>(jsHandleSetInterval)},
        {"jsHandleClearInterval",
                "(Ljava/lang/String;Ljava/lang/String;)V",
                reinterpret_cast<void *>(jsHandleClearInterval)},
        {"jsHandleCallGCanvasLinkNative",
                "(Ljava/lang/String;ILjava/lang/String;)V",
                reinterpret_cast<void *>(jsHandleCallGCanvasLinkNative)}
};


static bool RegisterNativesImpl(JNIEnv *env) {

    g_WXJsFunction_clazz = reinterpret_cast<jclass>(env->NewGlobalRef(
            base::android::GetClass(env, kWXJsFunctionClassPath).Get()));

    const int kMethodsWXJsFunctionsSize =
            sizeof(kMethodsWXJsFunctions) / sizeof(kMethodsWXJsFunctions[0]);

    return 0 <= env->RegisterNatives(WXJsFunction_clazz(env),
                                     kMethodsWXJsFunctions,
                                     kMethodsWXJsFunctionsSize);

}

#endif //WEEX_PROJECT_WXJSFUNCTIONS_JNI_H
