-
Notifications
You must be signed in to change notification settings - Fork 23
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
requested changes to java.c, configure.ac, and internal state to cobl… #150
Changes from 8 commits
e4b6f10
35f3ff4
1409cdf
10761c7
1ef39f0
e2722fc
2f20dea
3b5d860
52c90d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
2024-06-12 Vedant Tewari <[email protected]> | ||
|
||
* configure.ac: Add support for JNI (Java Native Interface) | ||
|
||
2023-02-25 Ron Norman <[email protected]> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,6 +146,8 @@ static struct literal_list *literal_cache = NULL; | |
static struct field_list *field_cache = NULL; | ||
static struct field_list *local_field_cache = NULL; | ||
static struct call_list *call_cache = NULL; | ||
extern JavaVM *jvm; | ||
extern JNIEnv *env; | ||
static struct call_list *func_call_cache = NULL; | ||
static struct static_call_list *static_call_cache = NULL; | ||
static struct base_list *base_cache = NULL; | ||
|
@@ -387,6 +389,21 @@ lookup_source (const char *p) | |
return source_id++; | ||
} | ||
|
||
static void lookup_java_call(const char *p) { | ||
struct call_list *clp; | ||
|
||
for (clp = call_cache; clp; clp = clp->next) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's another list you need to manipulate in this function. Something like |
||
if (strcmp(p, clp->call_name) == 0) { | ||
return; | ||
} | ||
} | ||
|
||
clp = (struct call_list *)cob_malloc(sizeof(struct call_list)); | ||
clp->call_name = p; | ||
clp->next = call_cache; | ||
call_cache = clp; | ||
} | ||
|
||
static void | ||
lookup_call (const char *p) | ||
{ | ||
|
@@ -7070,7 +7087,7 @@ output_call (struct cb_call *p) | |
ret_ptr = 1; | ||
} | ||
system_call = NULL; | ||
|
||
// check the name where it is translated, check if the string begins with java then encode the string differently | ||
#ifdef _WIN32 | ||
if (p->convention & CB_CONV_STDCALL) { | ||
convention = "_std"; | ||
|
@@ -7532,27 +7549,39 @@ output_call (struct cb_call *p) | |
if (name_is_literal_or_prototype) { | ||
s = get_program_id_str (p->name); | ||
name_str = cb_encode_program_id (s, 1, cb_fold_call); | ||
lookup_call (name_str); | ||
callname = s; | ||
#ifdef HAVE_JNI | ||
/* Distinguishing lookup from call*/ | ||
if(strncmp("Java.", name, 6) == 0) { | ||
void static_java_method = lookup_static_call(s + 6, p->argv[0], COB_RETURN_NULL); | ||
cob_call_java(static_java_method); | ||
} else { | ||
// rest | ||
#endif | ||
// we need to use lookup_java_call instead (implement) | ||
lookup_java_call (name_str); | ||
callname = s; | ||
|
||
output_line ("if (call_%s.funcvoid == NULL || cob_glob_ptr->cob_physical_cancel)", name_str); | ||
output_block_open (); | ||
output_prefix (); | ||
output_line ("if (call_%s.funcvoid == NULL || cob_glob_ptr->cob_physical_cancel)", name_str); | ||
output_block_open (); | ||
output_prefix (); | ||
|
||
nlp = find_nested_prog_with_id (name_str); | ||
if (nlp) { | ||
output ("call_%s.funcint = %s_%d__;", | ||
name_str, name_str, | ||
nlp->nested_prog->toplev_count); | ||
} else { | ||
output ("call_%s.funcvoid = ", name_str); | ||
output ("cob_resolve_cobol ("); | ||
output_string ((const unsigned char *)s, | ||
(int)strlen (s), 0); | ||
output (", %d, %d);", cb_fold_call, !p->stmt1); | ||
nlp = find_nested_prog_with_id (name_str); | ||
if (nlp) { | ||
output ("call_%s.funcint = %s_%d__;", | ||
name_str, name_str, | ||
nlp->nested_prog->toplev_count); | ||
} else { | ||
output ("call_%s.funcvoid = ", name_str); | ||
output ("cob_resolve_cobol ("); | ||
output_string ((const unsigned char *)s, | ||
(int)strlen (s), 0); | ||
output (", %d, %d);", cb_fold_call, !p->stmt1); | ||
} | ||
output_newline (); | ||
output_block_close (); | ||
#ifdef HAVE_JNI | ||
} | ||
output_newline (); | ||
output_block_close (); | ||
#endif | ||
} else { | ||
name_str = NULL; | ||
needs_unifunc = 1; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
2024-06-12 Vedant Tewari <[email protected]> | ||
|
||
* Makefile.am: Updated to include JNI-related files. | ||
* coblocal.h: Added internal state for JNI support. | ||
* java.c: Implemented JNI support for GnuCOBOL. | ||
|
||
2023-06-02 Simon Sobisch <[email protected]> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,12 @@ | |
# You should have received a copy of the GNU General Public License | ||
# along with GnuCOBOL. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
lib_LTLIBRARIES = libcob.la | ||
libcob_la_SOURCES = common.c move.c numeric.c strings.c \ | ||
fileio.c call.c intrinsic.c termio.c screenio.c reportio.c cobgetopt.c \ | ||
java.c \ | ||
mlio.c coblocal.h cconv.c system.def profiling.c | ||
Comment on lines
+22
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you likely just wanted to add java.c to the list below; later on you may include it conditional on a variable (similar but not identical to libodbci). In any case that's an adjustment, so please add |
||
|
||
if LOCAL_CJSON | ||
nodist_libcob_la_SOURCES = cJSON.c | ||
DISTCLEANFILES = cJSON.c cJSON.h | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure these are needed in the compiler (
cobc
) itself.