~ubuntu-branches/ubuntu/raring/libcaca/raring

« back to all changes in this revision

Viewing changes to java/caca_java_common.c

  • Committer: Bazaar Package Importer
  • Author(s): Sam Hocevar
  • Date: 2010-02-08 01:40:59 UTC
  • mfrom: (1.1.8 upstream) (4.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20100208014059-9q4av8pze8p7uw3i
Tags: 0.99.beta17-1
New upstream release.

Show diffs side-by-side

added added

removed removed

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