Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frameworks and fixes #253

Merged
merged 16 commits into from Jan 21, 2018
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
34a5adc
Fixed: RoboVmPlugin.getRoboVmModules extended to return only modules …
dkimitsa Jan 12, 2018
6c83589
Templater: added template for framework target, templater is modified…
dkimitsa Jan 12, 2018
86b6fc5
Templater: included framework template into root pom
dkimitsa Jan 12, 2018
17db26b
RoboVm libs: added framework support lib to make it easier to build f…
dkimitsa Jan 12, 2018
afeee1a
Framework target: linking with framework support lib
dkimitsa Jan 12, 2018
0184bb0
Idea: added RoboVM main menu, added Clean robovm cache and New projec…
dkimitsa Jan 12, 2018
257b7fb
Idea: added create framework functionality to RoboVM menu
dkimitsa Jan 12, 2018
9740908
Idea: added create framework functionality, missed plugin.xml added
dkimitsa Jan 12, 2018
452177c
Idea: added new RoboVM project/module type 'Framework target'
dkimitsa Jan 12, 2018
8b35f57
corrected framework support lib name to robovm-frameworksupport
dkimitsa Jan 12, 2018
0e985e0
Fixed completely broken “Add new module” functionality in Idea:
dkimitsa Jan 12, 2018
1b5090a
Fixed bug when launcher was putting get-task-allow: true for cases wh…
dkimitsa Jan 12, 2018
17e9b68
Fixed broken compilation of framework support lib
dkimitsa Jan 12, 2018
f1ae9ff
Fixed bug. it was tried to add menu twice this produced and warning t…
dkimitsa Jan 15, 2018
1f553f4
Added workaround to run Idea plugin in both Android studio and Idea
dkimitsa Jan 15, 2018
fd71297
Framework Template updated to generate Module map, this allows framew…
dkimitsa Jan 16, 2018
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+101 −0
Diff settings

Always

Just for now

RoboVm libs: added framework support lib to make it easier to build f…

…rameworks (no native code writing required)
  • Loading branch information...
dkimitsa committed Jan 12, 2018
commit 17db26b35f427de711f77ba4995290524da39122
@@ -290,3 +290,4 @@ add_subdirectory(core/src)
add_subdirectory(debug/src)
add_subdirectory(bc/src)
add_subdirectory(rt)
add_subdirectory(frameworksupport/src)
@@ -0,0 +1,12 @@
project(frameworks)

include_directories(../../core/include)

set(SRC
frameworksupport.m
)

add_library(robovm-frameworks STATIC ${SRC})

set_target_properties(robovm-frameworksupport PROPERTIES SUFFIX "${LIB_SUFFIX}")
install(TARGETS robovm-frameworksupport DESTINATION ${INSTALL_DIR})
@@ -0,0 +1,88 @@
/*
* Copyright 2016 Justin Shapcott.
*
* Licensed 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.
*/

#import <Foundation/Foundation.h>
#import "jni.h"

static dispatch_once_t once;
static id instance;
NSObject* rvmInstantiateFramework(const char *className) {
dispatch_once(&once, ^ {
JavaVMInitArgs vm_args;
JavaVM *vm;
JNIEnv *env;
jint res;

/*
* Create the RoboVM "VM" using standard the JNI JNI_CreateJavaVM() function
* which is exported by our framework.
*/
vm_args.version = JNI_VERSION_1_2;
vm_args.nOptions = 0;
vm_args.options = NULL;
res = JNI_CreateJavaVM(&vm, &env, &vm_args);
if (res != JNI_OK) {
[NSException raise:@"JNI_CreateJavaVM() failed" format:@"%d", res];
}

/*
* Lookup the root framework Java class that and call its initantiate() method to obtain Object instance
*/
char *jvmClassName = strdup(className);
for (char *p = jvmClassName; *p; p++) {
if (*p == '.')
*p = '/';
}
jclass cls = (*env)->FindClass(env, jvmClassName);
free(jvmClassName);
if (!cls) {
[NSException raise:@"Failed to find class" format:@"classname = %s", className];
}

/*
* Now lookup and call instantiate method to receive instance of framework class
*/
jmethodID mid = (*env)->GetStaticMethodID(env, cls, "instantiate", "()Lorg/robovm/apple/foundation/NSObject;");
if (!mid) {
[NSException raise:@"Failed to find method initialize()" format:@"classname = %s", className];
}
jobject jentry = (*env)->CallStaticObjectMethod(env, cls, mid);
if ((*env)->ExceptionOccurred(env)) {
[NSException raise:@"Call to initialize() failed" format:@"classname = %s", className];
}
if (jentry == NULL) {
[NSException raise:@"Call to method initialize() returned NULL object" format:@"classname = %s", className];
}

/*
* Now fetch pointer to objc object from java, calling NSObject.getHandle() for this
*/
cls = (*env)->FindClass(env, "org/robovm/apple/foundation/NSObject");
if (!cls) {
[NSException raise:@"Failed to find class NSObject" format:@""];
}
mid = (*env)->GetMethodID(env, cls, "getHandle", "()J");
if (!mid) {
[NSException raise:@"Failed to find method getHandle()" format:@""];
}

jlong ptr = (*env)->CallLongMethod(env, jentry, mid);
instance = (__bridge id)(void*)ptr;
});

return instance;
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.