/+junk/c_sdl_joypad_ducktape

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/c_sdl_joypad_ducktape

« back to all changes in this revision

Viewing changes to JSParser.c

  • Committer: Gustav Hartvigsson
  • Date: 2014-01-11 23:32:10 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20140111233210-2lnw8934cjd5p848
* reorganising code to be remove extra typedefs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#include <stdio.h>
2
2
#include <string.h>
3
 
#include <stdlib.h>
4
3
#include "game_utils.h"
5
4
#include "JSParser.h"
6
5
 
7
 
/*
 
6
/**
8
7
 * This file, as the rest of the project is under MIT license.
9
8
 * see http://opensource.org/licenses/MIT
10
9
 *
27
26
                                   char * file_name,
28
27
                                   char * script) {
29
28
  GameJSParser * self = malloc (sizeof(GameJSParser));
30
 
  if (file_name != NULL && script != NULL) {
 
29
  if (file_name != NULL && stript != NULL) {
31
30
    print_error (
32
31
      "You can not use both a script and a file when creating a GameJSParser.\n"
33
32
      "Exacly ONE of these must be used."
34
33
    );
35
34
    game_js_parser_free (self);
36
35
    return NULL;
37
 
  } else if (file_name == NULL && script == NULL) {
 
36
  } else if (file_name == NULL && stript == NULL) {
38
37
    print_error (
39
38
      "WARNING: No script or file is set when constructing GameJSParser"
40
39
    );
54
53
    game_js_parser_free (self);
55
54
    return NULL;
56
55
  }
57
 
  self->js_global = JS_NewGlobalObject (self->js_cx, &_js_global_class);
 
56
  self->js_global = JS_NewGlobalObject (self->js_cx, _js_global_class, NULL);
58
57
  if (!self->js_global) {
59
58
    print_error ( "Could not contruct the JS runtime global object.");
60
59
    game_js_parser_free (self);
93
92
  self->dump_data_func = func;
94
93
}
95
94
 
96
 
void game_js_parser_load_settings (GameJSParser * self, void * data) {
97
 
  GameJSParserLoadDataFunc func = self->load_data_func;
 
95
void * game_js_parser_load_settings (GameJSParser * self, void * data) {
 
96
  GameJSParserDumpDataFunc func = self->load_data_func;
98
97
  func (self, data);
99
98
}
100
99
void * game_js_parser_dump_settings (GameJSParser * self) {
101
100
  GameJSParserDumpDataFunc func = self->dump_data_func;
102
 
  return func (self);
 
101
  return  func (self);
103
102
}