Permalink
Browse files

uberhax: s/yajl/json/g to get around conflicts with yajl-ruby version…

… of libyajl
  • Loading branch information...
1 parent fe3bf81 commit b901940eccb15aa3cf75554ea2fb6587e583775a @tmm1 tmm1 committed Apr 27, 2010
Showing with 547 additions and 541 deletions.
  1. +11 −5 ext/extconf.rb
  2. +15 −15 ext/json.c
  3. +24 −24 ext/json.h
  4. +375 −375 ext/memprof.c
  5. +9 −9 ext/tracer.c
  6. +3 −3 ext/tracer.h
  7. +37 −37 ext/tracers/fd.c
  8. +5 −5 ext/tracers/gc.c
  9. +20 −20 ext/tracers/memcache.c
  10. +35 −35 ext/tracers/memory.c
  11. +5 −5 ext/tracers/mysql.c
  12. +8 −8 ext/tracers/objects.c
View
@@ -33,17 +33,23 @@ def sys(cmd)
sys("tar zxvf #{yajl}")
Dir.chdir("#{dir}/src") do
- FileUtils.mkdir_p "api/yajl"
+ sys("sed -i -e 's,yajl,json,g' *.h *.c api/*.h")
+ Dir['{,api/}yajl*.{h,c}'].each do |file|
+ FileUtils.mv file, file.gsub('yajl', 'json')
+ end
+
+ FileUtils.mkdir_p "api/json"
%w[ common parse gen ].each do |f|
- FileUtils.cp "api/yajl_#{f}.h", 'api/yajl/'
+ FileUtils.cp "api/json_#{f}.h", 'api/json/'
end
File.open("extconf.rb",'w') do |f|
f.puts "require 'mkmf'; $INCFLAGS[0,0] = '-I./api/ '; create_makefile 'libyajl'"
end
- sys("#{Config::CONFIG['bindir']}/#{Config::CONFIG['ruby_install_name']} extconf.rb")
+ sys("#{Config::CONFIG['bindir']}/#{Config::CONFIG['ruby_install_name']} extconf.rb")
sys("make")
+
if RUBY_PLATFORM =~ /darwin/
sys("libtool -static -o libyajl_ext.a #{Dir['*.o'].join(' ')}")
else
@@ -53,15 +59,15 @@ def sys(cmd)
FileUtils.mkdir_p "#{CWD}/dst/lib"
FileUtils.cp 'libyajl_ext.a', "#{CWD}/dst/lib"
FileUtils.mkdir_p "#{CWD}/dst/include"
- FileUtils.cp_r 'api/yajl', "#{CWD}/dst/include/"
+ FileUtils.cp_r 'api/json', "#{CWD}/dst/include/"
end
end
end
$LIBPATH.unshift "#{CWD}/dst/lib"
$INCFLAGS[0,0] = "-I#{CWD}/dst/include "
-unless have_library('yajl_ext') and have_header('yajl/yajl_gen.h')
+unless have_library('yajl_ext') and have_header('json/json_gen.h')
raise 'Yajl build failed'
end
View
@@ -9,44 +9,44 @@
#include <stdlib.h>
void
-yajl_gen_reset(yajl_gen gen)
+json_gen_reset(json_gen gen)
{
- yajl_gen_clear(gen);
- assert (gen->state[gen->depth] == yajl_gen_complete);
- gen->state[gen->depth] = yajl_gen_start;
+ json_gen_clear(gen);
+ assert (gen->state[gen->depth] == json_gen_complete);
+ gen->state[gen->depth] = json_gen_start;
gen->print(gen->ctx, "\n", 1);
}
-yajl_gen_status
-yajl_gen_cstr(yajl_gen gen, const char * str)
+json_gen_status
+json_gen_cstr(json_gen gen, const char * str)
{
if (!str || str[0] == 0)
- return yajl_gen_null(gen);
+ return json_gen_null(gen);
else
- return yajl_gen_string(gen, (unsigned char *)str, strlen(str));
+ return json_gen_string(gen, (unsigned char *)str, strlen(str));
}
-yajl_gen_status
-yajl_gen_format(yajl_gen gen, char *format, ...)
+json_gen_status
+json_gen_format(json_gen gen, char *format, ...)
{
va_list args;
char *str;
int bytes_printed = 0;
- yajl_gen_status ret;
+ json_gen_status ret;
va_start(args, format);
bytes_printed = vasprintf(&str, format, args);
assert(bytes_printed != -1);
va_end(args);
- ret = yajl_gen_string(gen, (unsigned char *)str, strlen(str));
+ ret = json_gen_string(gen, (unsigned char *)str, strlen(str));
free(str);
return ret;
}
-yajl_gen_status
-yajl_gen_pointer(yajl_gen gen, void* ptr)
+json_gen_status
+json_gen_pointer(json_gen gen, void* ptr)
{
- return yajl_gen_format(gen, "0x%x", ptr);
+ return json_gen_format(gen, "0x%x", ptr);
}
View
@@ -2,47 +2,47 @@
#define __JSON__H_
#include <stdarg.h>
-#include <yajl/yajl_gen.h>
+#include <json/json_gen.h>
-/* HAX: copied from internal yajl_gen.c (PATCH yajl before building instead)
+/* HAX: copied from internal json_gen.c (PATCH json before building instead)
*/
typedef enum {
- yajl_gen_start,
- yajl_gen_map_start,
- yajl_gen_map_key,
- yajl_gen_map_val,
- yajl_gen_array_start,
- yajl_gen_in_array,
- yajl_gen_complete,
- yajl_gen_error
-} yajl_gen_state;
-
-struct yajl_gen_t
+ json_gen_start,
+ json_gen_map_start,
+ json_gen_map_key,
+ json_gen_map_val,
+ json_gen_array_start,
+ json_gen_in_array,
+ json_gen_complete,
+ json_gen_error
+} json_gen_state;
+
+struct json_gen_t
{
unsigned int depth;
unsigned int pretty;
const char * indentString;
- yajl_gen_state state[YAJL_MAX_DEPTH];
- yajl_print_t print;
- void * ctx; /* yajl_buf */
+ json_gen_state state[YAJL_MAX_DEPTH];
+ json_print_t print;
+ void * ctx; /* json_buf */
/* memory allocation routines */
- yajl_alloc_funcs alloc;
+ json_alloc_funcs alloc;
};
/* END HAX
*/
void
-yajl_gen_reset(yajl_gen gen);
+json_gen_reset(json_gen gen);
-yajl_gen_status
-yajl_gen_cstr(yajl_gen gen, const char * str);
+json_gen_status
+json_gen_cstr(json_gen gen, const char * str);
-yajl_gen_status
-yajl_gen_format(yajl_gen gen, char *format, ...);
+json_gen_status
+json_gen_format(json_gen gen, char *format, ...);
-yajl_gen_status
-yajl_gen_pointer(yajl_gen gen, void* ptr);
+json_gen_status
+json_gen_pointer(json_gen gen, void* ptr);
#endif
Oops, something went wrong.

0 comments on commit b901940

Please sign in to comment.