move most previously global symbols to static to prevent conflicts (thanks for catching this Eric)

This commit is contained in:
Brian Lopez 2010-08-04 19:32:14 -07:00
parent 2bb8721e84
commit 12c022c8aa
3 changed files with 32 additions and 27 deletions

View File

@ -2,9 +2,10 @@
#include <client.h> #include <client.h>
VALUE cMysql2Client; VALUE cMysql2Client;
extern VALUE mMysql2, cMysql2Error, intern_encoding_from_charset; extern VALUE mMysql2, cMysql2Error;
extern ID sym_id, sym_version, sym_async, sym_symbolize_keys, sym_as, sym_array; static VALUE intern_encoding_from_charset;
extern ID intern_merge; static ID sym_id, sym_version, sym_async, sym_symbolize_keys, sym_as, sym_array;
static ID intern_merge;
#define REQUIRE_OPEN_DB(_ctxt) \ #define REQUIRE_OPEN_DB(_ctxt) \
if(!_ctxt->net.vio) { \ if(!_ctxt->net.vio) { \
@ -529,4 +530,15 @@ void init_mysql2_client() {
rb_define_private_method(cMysql2Client, "ssl_set", set_ssl_options, 5); rb_define_private_method(cMysql2Client, "ssl_set", set_ssl_options, 5);
rb_define_private_method(cMysql2Client, "init_connection", init_connection, 0); rb_define_private_method(cMysql2Client, "init_connection", init_connection, 0);
rb_define_private_method(cMysql2Client, "connect", rb_connect, 6); rb_define_private_method(cMysql2Client, "connect", rb_connect, 6);
intern_encoding_from_charset = rb_intern("encoding_from_charset");
sym_id = ID2SYM(rb_intern("id"));
sym_version = ID2SYM(rb_intern("version"));
sym_async = ID2SYM(rb_intern("async"));
sym_symbolize_keys = ID2SYM(rb_intern("symbolize_keys"));
sym_as = ID2SYM(rb_intern("as"));
sym_array = ID2SYM(rb_intern("array"));
intern_merge = rb_intern("merge");
} }

View File

@ -1,29 +1,12 @@
#include <mysql2_ext.h> #include <mysql2_ext.h>
VALUE mMysql2, cMysql2Error, intern_encoding_from_charset; VALUE mMysql2, cMysql2Error;
ID sym_id, sym_version, sym_async, sym_symbolize_keys, sym_as,
sym_array, sym_timezone, sym_utc, sym_local;
ID intern_merge;
/* Ruby Extension initializer */ /* Ruby Extension initializer */
void Init_mysql2() { void Init_mysql2() {
mMysql2 = rb_define_module("Mysql2"); mMysql2 = rb_define_module("Mysql2");
cMysql2Error = rb_const_get(mMysql2, rb_intern("Error")); cMysql2Error = rb_const_get(mMysql2, rb_intern("Error"));
intern_merge = rb_intern("merge");
sym_timezone = ID2SYM(rb_intern("timezone"));
sym_utc = ID2SYM(rb_intern("utc"));
sym_local = ID2SYM(rb_intern("local"));
sym_array = ID2SYM(rb_intern("array"));
sym_as = ID2SYM(rb_intern("as"));
sym_id = ID2SYM(rb_intern("id"));
sym_version = ID2SYM(rb_intern("version"));
sym_async = ID2SYM(rb_intern("async"));
sym_symbolize_keys = ID2SYM(rb_intern("symbolize_keys"));
intern_encoding_from_charset = rb_intern("encoding_from_charset");
init_mysql2_client(); init_mysql2_client();
init_mysql2_result(); init_mysql2_result();
} }

View File

@ -4,13 +4,13 @@
rb_encoding *binaryEncoding; rb_encoding *binaryEncoding;
#endif #endif
ID intern_new, intern_utc, intern_local, intern_encoding_from_charset_code;
VALUE cMysql2Result; VALUE cMysql2Result;
VALUE cBigDecimal, cDate, cDateTime; VALUE cBigDecimal, cDate, cDateTime;
extern VALUE mMysql2, cMysql2Client, cMysql2Error, intern_encoding_from_charset; extern VALUE mMysql2, cMysql2Client, cMysql2Error;
extern ID sym_symbolize_keys, sym_as, sym_array, sym_timezone, sym_local, sym_utc; static VALUE intern_encoding_from_charset;
extern ID intern_merge; static ID intern_new, intern_utc, intern_local, intern_encoding_from_charset_code;
static ID sym_symbolize_keys, sym_as, sym_array, sym_timezone, sym_local, sym_utc;
static ID intern_merge;
static void rb_mysql_result_mark(void * wrapper) { static void rb_mysql_result_mark(void * wrapper) {
mysql2_result_wrapper * w = wrapper; mysql2_result_wrapper * w = wrapper;
@ -367,10 +367,20 @@ void init_mysql2_result() {
rb_define_method(cMysql2Result, "each", rb_mysql_result_each, -1); rb_define_method(cMysql2Result, "each", rb_mysql_result_each, -1);
rb_define_method(cMysql2Result, "fields", rb_mysql_result_fetch_fields, 0); rb_define_method(cMysql2Result, "fields", rb_mysql_result_fetch_fields, 0);
intern_encoding_from_charset = rb_intern("encoding_from_charset");
intern_encoding_from_charset_code = rb_intern("encoding_from_charset_code");
intern_new = rb_intern("new"); intern_new = rb_intern("new");
intern_utc = rb_intern("utc"); intern_utc = rb_intern("utc");
intern_local = rb_intern("local"); intern_local = rb_intern("local");
intern_encoding_from_charset_code = rb_intern("encoding_from_charset_code"); intern_merge = rb_intern("merge");
sym_symbolize_keys = ID2SYM(rb_intern("symbolize_keys"));
sym_as = ID2SYM(rb_intern("as"));
sym_array = ID2SYM(rb_intern("array"));
sym_timezone = ID2SYM(rb_intern("timezone"));
sym_local = ID2SYM(rb_intern("local"));
sym_utc = ID2SYM(rb_intern("utc"));
#ifdef HAVE_RUBY_ENCODING_H #ifdef HAVE_RUBY_ENCODING_H
binaryEncoding = rb_enc_find("binary"); binaryEncoding = rb_enc_find("binary");