-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mxj_safe: an extension to protect users and provide a reasonable user…
… experience when java is not installed. it does not resolve the problems with having java8 and not java6 however. see #8.
- Loading branch information
Timothy Place
committed
May 24, 2016
1 parent
005bfa6
commit 4272aaa
Showing
6 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
*.x86_64 | ||
*.hex | ||
externals | ||
extensions | ||
|
||
# Xcode User Data | ||
project.xcworkspace | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "source/max-api"] | ||
path = source/max-api | ||
url = https://github.com/Cycling74/max-api.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
|
||
set(C74_BUILD_MAX_EXTENSION TRUE) | ||
include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-api/script/max-pretarget.cmake) | ||
|
||
|
||
include_directories( | ||
"${C74_INCLUDES}" | ||
) | ||
|
||
|
||
add_library( | ||
${PROJECT_NAME} | ||
MODULE | ||
${PROJECT_NAME}.cpp | ||
) | ||
|
||
|
||
include(${CMAKE_CURRENT_SOURCE_DIR}/../../max-api/script/max-posttarget.cmake) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
// Copyright (c) 2016, Cycling '74 | ||
// Timothy Place | ||
// Usage of this file and its contents is governed by the MIT License | ||
|
||
|
||
#include "c74_msp.h" | ||
|
||
using namespace c74::max; | ||
|
||
|
||
#define DEFAULT_OS_ARCH "x86_64" // do we need to worry about 32-bit? | ||
#include "../../mxj/JavaHomeOsx.c" | ||
#include <dlfcn.h> | ||
#include <string> | ||
|
||
|
||
bool java_installed() { | ||
char* baseDir = getJavaHome(); | ||
|
||
if (baseDir == nullptr || !strcmp(baseDir, "/")) | ||
return false; | ||
else | ||
return true; | ||
} | ||
|
||
|
||
static t_class *mxj_class = nullptr; | ||
static t_class *mxj_tilde_class = nullptr; | ||
|
||
|
||
|
||
struct mxj_safe { | ||
t_pxobject base; | ||
}; | ||
|
||
|
||
mxj_safe* mxj_safe_new(t_symbol* name, long ac, t_atom* av) { | ||
mxj_safe* self; | ||
|
||
if (name == gensym("mxj~")) | ||
self = (mxj_safe*)object_alloc(mxj_class); | ||
else | ||
self = (mxj_safe*)object_alloc(mxj_class); | ||
|
||
object_error_obtrusive((t_object*)self, "Java is not installed on this computer. Please install it from https://support.apple.com/kb/DL1572?locale=en_US."); | ||
return self; | ||
} | ||
|
||
|
||
void ext_main(void* r) { | ||
if (java_installed()) { | ||
// object_post(nullptr, "java is installed... nothing to see... please move along..."); | ||
} | ||
else { | ||
// object_error(nullptr, "java is not installed... defining dummies!"); | ||
|
||
auto c = class_new("mxj", (method)mxj_safe_new, nullptr, sizeof(mxj_safe), nullptr, A_GIMME, 0); | ||
class_addmethod(c, (method)method_false, "int", A_LONG, 0); | ||
class_addmethod(c, (method)method_false, "float", A_FLOAT, 0); | ||
class_addmethod(c, (method)method_false, "bang", 0); | ||
class_addmethod(c, (method)method_false, "list", A_GIMME, 0); | ||
class_addmethod(c, (method)method_false, "anything", A_GIMME, 0); | ||
class_addmethod(c, (method)method_false, "viewsource", A_GIMME, 0); | ||
class_addmethod(c, (method)method_false, "zap", A_GIMME, 0); | ||
class_addmethod(c, (method)method_false, "quickref",A_CANT,0); | ||
class_addmethod(c, (method)method_false, "assist", A_CANT, 0); | ||
class_addmethod(c, (method)method_false, "get", A_GIMME, 0); | ||
class_addmethod(c, (method)method_false, "objectfilename", A_CANT, 0); | ||
class_addmethod(c, (method)method_false, "save2", A_CANT, 0); | ||
class_addmethod(c, (method)method_false, "loadbang",A_CANT,0); | ||
class_addmethod(c, (method)method_false, "dblclick",A_CANT,0); | ||
class_addmethod(c, (method)method_false, "fileusage", A_CANT, 0); | ||
class_register(CLASS_BOX, c); | ||
mxj_class = c; | ||
|
||
object_method_direct(void, (t_object*, t_symbol*, t_symbol*, t_symbol*), | ||
gensym("max")->s_thing, gensym("objectfile"), gensym("mxj"), gensym("mxj_safe"), gensym("mxj")); | ||
|
||
|
||
|
||
c = class_new("mxj~", (method)mxj_safe_new, nullptr, sizeof(mxj_safe), nullptr, A_GIMME, 0); | ||
class_dspinit(c); | ||
class_addmethod(c, (method)method_false, "int", A_LONG, 0); | ||
class_addmethod(c, (method)method_false, "float", A_FLOAT, 0); | ||
class_addmethod(c, (method)method_false, "bang", 0); | ||
class_addmethod(c, (method)method_false, "list", A_GIMME, 0); | ||
class_addmethod(c, (method)method_false, "anything", A_GIMME, 0); | ||
class_addmethod(c, (method)method_false, "viewsource", A_GIMME, 0); | ||
class_addmethod(c, (method)method_false, "zap", A_GIMME, 0); | ||
class_addmethod(c, (method)method_false, "quickref",A_CANT,0); | ||
class_addmethod(c, (method)method_false, "assist", A_CANT, 0); | ||
class_addmethod(c, (method)method_false, "get", A_GIMME, 0); | ||
class_addmethod(c, (method)method_false, "objectfilename", A_CANT, 0); | ||
class_addmethod(c, (method)method_false, "save2", A_CANT, 0); | ||
class_addmethod(c, (method)method_false, "loadbang",A_CANT,0); | ||
class_addmethod(c, (method)method_false, "dblclick",A_CANT,0); | ||
class_addmethod(c, (method)method_false, "fileusage", A_CANT, 0); | ||
//class_addmethod(c, (method)mxj_dsp64, "dsp64", A_CANT, 0); | ||
//class_addmethod(c, (method)mxj_dspstate, "dspstate", A_CANT, 0); | ||
//class_addmethod(c, (method)mxj_benchmark, "benchmark",A_DEFLONG,A_DEFLONG,0); | ||
//class_addmethod(c, (method)mxj_exception_check, "exceptioncheck",A_DEFLONG,0); | ||
class_register(CLASS_BOX, c); | ||
mxj_tilde_class = c; | ||
|
||
object_method_direct(void, (t_object*, t_symbol*, t_symbol*, t_symbol*), | ||
gensym("max")->s_thing, gensym("objectfile"), gensym("mxj~"), gensym("mxj_safe"), gensym("mxj~")); | ||
|
||
|
||
} | ||
} | ||
|
||
|