Skip to content

Commit

Permalink
Fixed varargs fail that caused the VM to crash horribly.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Gramlich committed Mar 2, 2012
1 parent f1697de commit 6bfb205
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 32 deletions.
7 changes: 4 additions & 3 deletions jni/src/EntityProxy.cpp
Expand Up @@ -27,7 +27,7 @@ EntityProxy::EntityProxy(float pX, float pY) {

jmethodID constructor = JNI_ENV()->GetMethodID(clazz, "<init>", "(JFF)V");

this->mUnwrapped = JNI_ENV()->NewObject(clazz, constructor, this, pX, pY);
this->mUnwrapped = JNI_ENV()->NewObject(clazz, constructor, (jlong)this, pX, pY);
}

void EntityProxy::setRotation(float pRotation) {
Expand All @@ -47,8 +47,9 @@ void EntityProxy::setScale(float pScale) {
}

bool EntityProxy::onAttached() {
// this->setRotation(45);
return false;
this->setScale(2);

return true;
}

bool EntityProxy::onDetached() {
Expand Down
2 changes: 1 addition & 1 deletion jni/src/RectangleProxy.cpp
Expand Up @@ -26,5 +26,5 @@ RectangleProxy::RectangleProxy(float pX, float pY, float pWidth, float pHeight,

jmethodID constructor = JNI_ENV()->GetMethodID(clazz, "<init>", "(JFFFFLorg/andengine/opengl/vbo/VertexBufferObjectManager;)V");

this->mUnwrapped = JNI_ENV()->NewObject(clazz, constructor, this, pX, pY, pWidth, pHeight, pVertexBufferObjectManager);
this->mUnwrapped = JNI_ENV()->NewObject(clazz, constructor, (jlong)this, pX, pY, pWidth, pHeight, pVertexBufferObjectManager);
}
23 changes: 3 additions & 20 deletions jni/src/Test.cpp
@@ -1,10 +1,7 @@
#include "ScriptingEnvironment.h"
#include "Test.h"
#include "RectangleProxy.h"
#include <android/log.h>

#define LOG_TAG "AndEngine"
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
#include "Util.h"

// ===========================================================
// org.andengine.extension.scripting.Test
Expand All @@ -15,23 +12,9 @@ JNIEXPORT jobject JNICALL Java_org_andengine_extension_scripting_Test_mirror(JNI
}

JNIEXPORT jobject JNICALL Java_org_andengine_extension_scripting_Test_test(JNIEnv* pJNIEnv, jclass pJClass) {
LOGD("test(1)");

jobject vertexBufferObjectManager = getEngine()->getVertexBufferObjectManager();

// LOGD(getClassName(vertexBufferObjectManager));

RectangleProxy* rect = new RectangleProxy(10, 10, 100, 100, vertexBufferObjectManager);

LOGD("test(2)");
RectangleProxy* rect = new RectangleProxy(10, 10, 100, 100, getEngine()->getVertexBufferObjectManager());

rect->setRotation(45);

LOGD("test(3)");

jobject unwrapped = rect->unwrap();

LOGD("test(4)");

return unwrapped;
return rect->unwrap();
}
11 changes: 11 additions & 0 deletions jni/src/Util.h
@@ -0,0 +1,11 @@
#ifndef Util_H
#define Util_H

#include <android/log.h>

#define LOG_TAG "AndEngineScriptingExtension"
#define LOG_D(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
#define LOG_W(...) __android_log_print(ANDROID_LOG_WARNING,LOG_TAG,__VA_ARGS__)
#define LOG_E(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)

#endif
Binary file not shown.
Binary file added libs/armeabi-v7a/libgnustl_shared.so
Binary file not shown.
Binary file added libs/armeabi/libandenginescriptingextension.so
Binary file not shown.
Binary file added libs/armeabi/libgnustl_shared.so
Binary file not shown.
Binary file added libs/x86/libandenginescriptingextension.so
Binary file not shown.
Binary file added libs/x86/libgnustl_shared.so
Binary file not shown.
8 changes: 4 additions & 4 deletions src/org/andengine/extension/scripting/entity/EntityProxy.java
Expand Up @@ -39,18 +39,18 @@ public EntityProxy(final long pAddress, final float pX, final float pY) {

@Override
public void onAttached() {
// if(!this.nativeOnAttached(this.mAddress)) {
if(!this.nativeOnAttached(this.mAddress)) {
super.onAttached();
// }
}
}

private native boolean nativeOnAttached(final long pAddress);

@Override
public void onDetached() {
// if(!this.nativeOnDetached(this.mAddress)) {
if(!this.nativeOnDetached(this.mAddress)) {
super.onDetached();
// }
}
}

private native boolean nativeOnDetached(final long pAddress);
Expand Down
Expand Up @@ -47,18 +47,18 @@ public RectangleProxy(final long pAddress, final float pX, final float pY, final

@Override
public void onAttached() {
// if(!this.nativeOnAttached(this.mAddress)) {
if(!this.nativeOnAttached(this.mAddress)) {
super.onAttached();
// }
}
}

private native boolean nativeOnAttached(final long pAddress);

@Override
public void onDetached() {
// if(!this.nativeOnDetached(this.mAddress)) {
if(!this.nativeOnDetached(this.mAddress)) {
super.onDetached();
// }
}
}

private native boolean nativeOnDetached(final long pAddress);
Expand Down

0 comments on commit 6bfb205

Please sign in to comment.