source: libcaca/trunk/java/caca_java_common.c @ 4197

Last change on this file since 4197 was 4197, checked in by Sam Hocevar, 13 years ago

Java bindings, courtesy of Adrien Grand <jpountz@dinauz.org>.

File size: 909 bytes
Line 
1/*
2 *  libcaca       Java bindings for libcaca
3 *  Copyright (c) 2009 Adrien Grand <jpountz@dinauz.org>
4 *
5 *  $Id$
6 *
7 *  This library is free software. It comes without any warranty, to
8 *  the extent permitted by applicable law. You can redistribute it
9 *  and/or modify it under the terms of the Do What The Fuck You Want
10 *  To Public License, Version 2, as published by Sam Hocevar. See
11 *  http://sam.zoy.org/wtfpl/COPYING for more details.
12 */
13
14#include "caca_java_common.h"
15
16jobjectArray caca_java_to_string_array(JNIEnv *env, const char *const *v)
17{
18  jclass java_lang_string = (*env)->FindClass(env, "java/lang/String");
19  jsize size;
20  jsize i;
21
22  for (size = 0; v[size]; ++size);
23
24  jobjectArray ret = (*env)->NewObjectArray(env, size, java_lang_string, NULL);
25  for (i = 0; i < size; ++i)
26  {
27    (*env)->SetObjectArrayElement(env, ret, i, (*env)->NewStringUTF(env, v[i]));
28  }
29  return ret;
30}
31
Note: See TracBrowser for help on using the repository browser.