Code

Improve 'dirty' editor handling
[inkscape.git] / src / bind / javabind-private.h
1 #ifndef __JAVABIND_PRIVATE_H__
2 #define __JAVABIND_PRIVATE_H__
3 /**
4  * This is a simple mechanism to bind Inkscape to Java, and thence
5  * to all of the nice things that can be layered upon that. 
6  *
7  * Authors:
8  *   Bob Jamison
9  *
10  * Copyright (C) 2007-2008 Bob Jamison
11  *
12  *  This library is free software; you can redistribute it and/or
13  *  modify it under the terms of the GNU Lesser General Public
14  *  License as published by the Free Software Foundation; either
15  *  version 2.1 of the License, or (at your option) any later version.
16  *
17  *  This library is distributed in the hope that it will be useful,
18  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  *  Lesser General Public License for more details.
21  *
22  *  You should have received a copy of the GNU Lesser General Public
23  *  License along with this library; if not, write to the Free Software
24  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25  */
27 #include <jni.h>
29 #include "javabind.h"
33 namespace Inkscape
34 {
36 namespace Bind
37 {
40 class JavaBinderyImpl : public JavaBindery
41 {
42 public:
44     JavaBinderyImpl();
45     
46     virtual ~JavaBinderyImpl();
47     
48     virtual bool loadJVM();
49     
50     virtual bool callStatic(int type,
51                             const String &className,
52                             const String &methodName,
53                             const String &signature,
54                             const std::vector<Value> &params,
55                             Value &retval);
57     virtual bool callInstance(
58                                                         int type,
59                                 const jobject obj,
60                             const String &methodName,
61                             const String &signature,
62                             const std::vector<Value> &params,
63                             Value &retval);
65     virtual bool callMain(const String &className,
66                               const std::vector<String> &args);
68     virtual bool isLoaded();
70     /**
71      *
72      */
73     virtual bool scriptRun(const String &lang, const String &script);
75     /**
76      *
77      */
78     virtual bool scriptRunFile(const String &lang, const String &fileName);
80     virtual bool showConsole();
82     virtual bool registerNatives(const String &className,
83                                  const JNINativeMethod *methods);
84  
85     virtual bool doBinding();
87     virtual String getException();
89     virtual bool setupGateway();
91     static JavaBinderyImpl *getInstance();
94 private:
96     JavaVM *jvm;
97     JNIEnv  *env;
98     jobject gatewayObj;
99 };
102 //########################################################################
103 //# MESSAGES
104 //########################################################################
106 void err(const char *fmt, ...);
108 void msg(const char *fmt, ...);
110 //########################################################################
111 //# UTILITY
112 //########################################################################
114 String normalizePath(const String &str);
116 String getExceptionString(JNIEnv *env);
118 jint getInt(JNIEnv *env, jobject obj, const char *name);
120 void setInt(JNIEnv *env, jobject obj, const char *name, jint val);
122 jlong getLong(JNIEnv *env, jobject obj, const char *name);
124 void setLong(JNIEnv *env, jobject obj, const char *name, jlong val);
126 jfloat getFloat(JNIEnv *env, jobject obj, const char *name);
128 void setFloat(JNIEnv *env, jobject obj, const char *name, jfloat val);
130 jdouble getDouble(JNIEnv *env, jobject obj, const char *name);
132 void setDouble(JNIEnv *env, jobject obj, const char *name, jdouble val);
134 String getString(JNIEnv *env, jobject obj, const char *name);
136 void setString(JNIEnv *env, jobject obj, const char *name, const String &val);
140 } // namespace Bind
141 } // namespace Inkscape
143 #endif /* __JAVABIND_PRIVATE_H__ */
144 //########################################################################
145 //# E N D    O F    F I L E
146 //########################################################################