OSDN Git Service

First GIT commit on Sourceforge.jp: added sudokuki main branch to GIT.
[sudokuki/sudokuki.git] / RELEASE / sudokuki / src / classes / net / jankenpoi / sudokuki / generator / suexg / suexg_proxy.c
1 /*
2  * Sudokuki - essential sudoku game
3  * Copyright (C) 2007-2011 Sylvain Vedrenne
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 #include <stdlib.h>
19
20 #include "suexg/gene_suexg_v12.h"
21
22 #include "net_jankenpoi_sudokuki_generator_suexg_SuexgProxy.h"
23
24 /*
25  * Class:     net_jankenpoi_sudokuki_generator_suexg_SuexgProxy
26  * Method:    generateSuexgGrid
27  * Signature: (III[I[I[I)I
28  */
29 JNIEXPORT jint JNICALL Java_net_jankenpoi_sudokuki_generator_suexg_SuexgProxy_generateSuexgGrid
30   (JNIEnv * env, jobject j_obj, jint seed, jint requestedRatingMin, jint requestedRatingMax, jintArray result_grid, jintArray result_rating, jintArray result_grid_and_clues)
31 {
32         //printf("\nBEGINNING OF PROXY NATIVE METHOD\n");
33
34         jint* grid = malloc(81 * sizeof(int));
35     jint* grid_and_clues = malloc(81 * sizeof(int));
36
37         //printf("grid before call to suexg code:\n");
38
39         //int i = 0;
40         //for (i=0; i<81; i++) {
41         //              printf("%d", grid[i]);
42         //}
43
44         //printf("\n");
45
46         jint rating = -2;
47         grid_generate (seed, requestedRatingMin, requestedRatingMax, (int**)&grid, (int*)&rating, (int**)&grid_and_clues );
48
49         //printf("after call to grid_generate - rating:%d\n", rating);
50
51         //printf("grid:\n");
52
53         //for (i=0; i<81; i++) {
54         //              printf("%d", grid[i]);
55         //}
56
57         //printf("\n");
58
59         //printf("returning grid:0x%x\n", grid);
60
61         (*env)->SetIntArrayRegion(env, result_grid, 0, 81, grid);
62         (*env)->SetIntArrayRegion(env, result_rating, 0, 1, &rating);
63         (*env)->SetIntArrayRegion(env, result_grid_and_clues, 0, 81, grid_and_clues);
64
65         //printf("END OF PROXY NATIVE METHOD\n");
66
67         return 0;
68 }