/**
 * 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
//     incubator-weex/weex_core/Source/android/jniprebuild/jni_generator.py
// For
//     org/apache/weex/ui/component/list/template/jni/NativeRenderObjectUtils

#ifndef com_taobao_weex_ui_component_list_template_jni_NativeRenderObjectUtils_JNI
#define com_taobao_weex_ui_component_list_template_jni_NativeRenderObjectUtils_JNI

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

// Step 1: forward declarations.
namespace {
const char kNativeRenderObjectUtilsClassPath[] =
    "org/apache/weex/ui/component/list/template/jni/NativeRenderObjectUtils";
// Leaking this jclass as we cannot use LazyInstance from some threads.
jclass g_NativeRenderObjectUtils_clazz = NULL;
#define NativeRenderObjectUtils_clazz(env) g_NativeRenderObjectUtils_clazz

}  // namespace

static jlong GetRenderObject(JNIEnv* env, jclass jcaller,
    jstring instanceId,
    jstring ref);

static void UpdateRenderObjectStyle(JNIEnv* env, jclass jcaller,
    jlong ptr,
    jstring key,
    jstring value);

static void UpdateRenderObjectAttr(JNIEnv* env, jclass jcaller,
    jlong ptr,
    jstring key,
    jstring value);

static jlong CopyRenderObject(JNIEnv* env, jclass jcaller,
    jlong ptr);

static jint LayoutRenderObject(JNIEnv* env, jclass jcaller,
    jlong ptr,
    jfloat width,
    jfloat height);

static void AddChildRenderObject(JNIEnv* env, jclass jcaller,
    jlong parent,
    jlong child);

static jint RenderObjectGetLayoutDirectionFromPathNode(JNIEnv* env, jclass jcaller,
    jlong ptr);

static jboolean RenderObjectHasNewLayout(JNIEnv* env, jclass jcaller,
    jlong ptr);

static jint RenderObjectChildCount(JNIEnv* env, jclass jcaller,
    jlong ptr);

static jlong RenderObjectGetChild(JNIEnv* env, jclass jcaller,
    jlong ptr,
    jint index);

static void RenderObjectUpdateComponent(JNIEnv* env, jclass jcaller,
    jlong ptr,
    jobject component);

static void RenderObjectChildWaste(JNIEnv* env, jclass jcaller,
    jlong ptr,
    jboolean waster);

// Step 2: method stubs.

static intptr_t g_NativeRenderObjectUtils_updateComponentSize = 0;
static void Java_NativeRenderObjectUtils_updateComponentSize(JNIEnv* env,
    jobject component,
    jfloat top,
    jfloat bottom,
    jfloat left,
    jfloat right,
    jfloat height,
    jfloat width) {
  /* Must call RegisterNativesImpl()  */
  //CHECK_CLAZZ(env, NativeRenderObjectUtils_clazz(env),
  //    NativeRenderObjectUtils_clazz(env));
  jmethodID method_id =
      base::android::GetMethod(
      env, NativeRenderObjectUtils_clazz(env),
      base::android::STATIC_METHOD,
      "updateComponentSize",

"("
"Lorg/apache/weex/ui/component/WXComponent;"
"F"
"F"
"F"
"F"
"F"
"F"
")"
"V",
      &g_NativeRenderObjectUtils_updateComponentSize);

     env->CallStaticVoidMethod(NativeRenderObjectUtils_clazz(env),
          method_id, component, top, bottom, left, right, height, width);
  base::android::CheckException(env);

}

// Step 3: RegisterNatives.

static const JNINativeMethod kMethodsNativeRenderObjectUtils[] = {
    { "nativeGetRenderObject",
"("
"Ljava/lang/String;"
"Ljava/lang/String;"
")"
"J", reinterpret_cast<void*>(GetRenderObject) },
    { "nativeUpdateRenderObjectStyle",
"("
"J"
"Ljava/lang/String;"
"Ljava/lang/String;"
")"
"V", reinterpret_cast<void*>(UpdateRenderObjectStyle) },
    { "nativeUpdateRenderObjectAttr",
"("
"J"
"Ljava/lang/String;"
"Ljava/lang/String;"
")"
"V", reinterpret_cast<void*>(UpdateRenderObjectAttr) },
    { "nativeCopyRenderObject",
"("
"J"
")"
"J", reinterpret_cast<void*>(CopyRenderObject) },
    { "nativeLayoutRenderObject",
"("
"J"
"F"
"F"
")"
"I", reinterpret_cast<void*>(LayoutRenderObject) },
    { "nativeAddChildRenderObject",
"("
"J"
"J"
")"
"V", reinterpret_cast<void*>(AddChildRenderObject) },
    { "nativeRenderObjectGetLayoutDirectionFromPathNode",
"("
"J"
")"
"I", reinterpret_cast<void*>(RenderObjectGetLayoutDirectionFromPathNode) },
    { "nativeRenderObjectHasNewLayout",
"("
"J"
")"
"Z", reinterpret_cast<void*>(RenderObjectHasNewLayout) },
    { "nativeRenderObjectChildCount",
"("
"J"
")"
"I", reinterpret_cast<void*>(RenderObjectChildCount) },
    { "nativeRenderObjectGetChild",
"("
"J"
"I"
")"
"J", reinterpret_cast<void*>(RenderObjectGetChild) },
    { "nativeRenderObjectUpdateComponent",
"("
"J"
"Lorg/apache/weex/ui/component/WXComponent;"
")"
"V", reinterpret_cast<void*>(RenderObjectUpdateComponent) },
    { "nativeRenderObjectChildWaste",
"("
"J"
"Z"
")"
"V", reinterpret_cast<void*>(RenderObjectChildWaste) },
};

static bool RegisterNativesImpl(JNIEnv* env) {

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

  const int kMethodsNativeRenderObjectUtilsSize =
      sizeof(kMethodsNativeRenderObjectUtils)/sizeof(kMethodsNativeRenderObjectUtils[0]);

  if (env->RegisterNatives(NativeRenderObjectUtils_clazz(env),
                           kMethodsNativeRenderObjectUtils,
                           kMethodsNativeRenderObjectUtilsSize) < 0) {
    //jni_generator::HandleRegistrationError(
    //    env, NativeRenderObjectUtils_clazz(env), __FILE__);
    return false;
  }

  return true;
}

#endif  // com_taobao_weex_ui_component_list_template_jni_NativeRenderObjectUtils_JNI
