/+junk/c_sdl_joypad_ducktape

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/c_sdl_joypad_ducktape
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* c-basic-offset: 2; tab-width: 2; indent-tabs-mode: nil
 * vi: set shiftwidth=2 tabstop=2 expandtab:
 * :indentSize=2:tabSize=2:noTabs=true:
 */

#ifndef __H_JS_PARSER__
#define __H_JS_PARSER__

/** @file
 * 
 *
 * Author Gustav Hartvigsson <gustav.hartvigsson _at_ gmail.com> 2014
 *
 */

#include "duktape.h"
#include "Game.h"

/******************************************************************************/

typedef struct GameJSParser GameJSParser;

/**
 * Function prototype to be used for loading context data, this is user-defined
 * so any data can be loaded into the JS context.
 */
typedef void (* GameJSParserLoadDataFunc)(GameJSParser * self, void * data);

/**
 * Function that is used to dump data from the JS context, it is user-defined.
 */
typedef void * (* GameJSParserDumpDataFunc)(GameJSParser * self);

/**
 * The data structure that represents the EcmaScript/JavaScript parser/engine
 * that can be used when creating games.
 */
typedef struct GameJSParser {
  GameJSParserLoadDataFunc load_data_func;
  GameJSParserDumpDataFunc dump_data_func;
  
  duk_context * ctx;
  duk_function_list_entry * function_array;
  
  Game * game; /**< DO NOT FREE! */
  
  char * file_name;
  char * script;
} GameJSParser;

/******************************************************************************/

/**
 * Need to know a bit about the game, like screen and renderer and such.
 *
 * Note that file_name and script parameters are mutually exclusive. If both are
 * set, the function will return NULL, and print an error to stderr.
 */
GameJSParser * game_js_parser_new (Game * game,
                                   char * file_name,
                                   char * script);

/**
 * 
 */
void game_js_parser_free (GameJSParser * self);

/**
 * 
 */
void game_js_parser_set_settings_loader (GameJSParser * self,
                                              GameJSParserLoadDataFunc func);

void game_js_parser_set_settings_dump (GameJSParser * self,
                                              GameJSParserDumpDataFunc func);

void game_js_parser_load_settings (GameJSParser * self, void * data);

void * game_js_parser_dump_settings (GameJSParser * self);


void game_js_parser_run (GameJSParser * self);

/******************************************************************************/


#endif