Skip to content
This repository has been archived by the owner on Aug 18, 2018. It is now read-only.

Commit

Permalink
silencing warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed May 22, 2008
1 parent 6100597 commit 9d019b6
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 68 deletions.
97 changes: 51 additions & 46 deletions ext/spidermonkey/debugger.c
@@ -1,111 +1,116 @@
#include "debugger.h"
#include "context.h"

static JSTrapStatus interrupt_handler(JSContext *js, JSScript *script,
jsbytecode *pc, jsval *rval, void *rb)
static JSTrapStatus interrupt_handler(JSContext *UNUSED(js), JSScript *UNUSED(script),
jsbytecode *UNUSED(pc), jsval *UNUSED(rval), void *rb)
{
VALUE context = (VALUE)JS_GetContextPrivate(js);
VALUE self = (VALUE)rb;
rb_funcall(self, rb_intern("interrupt_handler"), 1, context);
/* FIXME: Pass this stuff to the debugger. */
rb_funcall(self, rb_intern("interrupt_handler"), 0);
return JSTRAP_CONTINUE;
}

static void new_script_hook(JSContext *js,
const char *filename,
uintN lineno,
JSScript *script,
JSFunction *fun,
static void new_script_hook(JSContext *UNUSED(js),
const char *UNUSED(filename),
uintN UNUSED(lineno),
JSScript *UNUSED(script),
JSFunction *UNUSED(fun),
void *rb)
{
VALUE context = (VALUE)JS_GetContextPrivate(js);
VALUE self = (VALUE)rb;
rb_funcall(self, rb_intern("new_script_hook"), 1, context);

/* FIXME: Pass this crap to the debugger */
rb_funcall(self, rb_intern("new_script_hook"), 0);
}

static void destroy_script_hook(JSContext *js,
JSScript *script,
static void destroy_script_hook(JSContext *UNUSED(js),
JSScript *UNUSED(script),
void *rb)
{
VALUE context = (VALUE)JS_GetContextPrivate(js);
VALUE self = (VALUE)rb;
rb_funcall(self, rb_intern("destroy_script_hook"), 1, context);
rb_funcall(self, rb_intern("destroy_script_hook"), 0);
}

static JSTrapStatus debugger_handler(JSContext *js, JSScript *script,
jsbytecode *pc, jsval *rval, void *rb)
static JSTrapStatus debugger_handler(JSContext *UNUSED(js), JSScript *UNUSED(script),
jsbytecode *UNUSED(pc), jsval *UNUSED(rval), void *rb)
{
VALUE context = (VALUE)JS_GetContextPrivate(js);
VALUE self = (VALUE)rb;
rb_funcall(self, rb_intern("debugger_handler"), 1, context);
/* FIXME: Pass this crap to the debugger? */
rb_funcall(self, rb_intern("debugger_handler"), 0);
return JSTRAP_CONTINUE;
}

static void source_handler(const char *filename, uintN lineno,
jschar *str, size_t length,
void **listenerTSData, void *rb)
jschar *UNUSED(str), size_t UNUSED(length),
void **UNUSED(listenerTSData), void *rb)
{
VALUE self = (VALUE)rb;
rb_funcall(self, rb_intern("source_handler"), 0);
VALUE rb_filename = rb_str_new2(filename);
VALUE rb_lineno = INT2NUM((int)lineno);

rb_funcall(self, rb_intern("source_handler"), 2, rb_filename, rb_lineno);
}

static void * execute_hook(JSContext *js, JSStackFrame *fp, JSBool before,
JSBool *ok, void *rb)
static void * execute_hook(JSContext *UNUSED(js), JSStackFrame *UNUSED(fp), JSBool before,
JSBool *UNUSED(ok), void *rb)
{
VALUE context = (VALUE)JS_GetContextPrivate(js);
VALUE self = (VALUE)rb;
rb_funcall(self, rb_intern("execute_hook"), 1, context);
VALUE rb_before = JS_TRUE == before ? Qtrue : Qfalse;

/* FIXME: Should OK be passed? */
rb_funcall(self, rb_intern("execute_hook"), 1, rb_before);
return rb;
}

static void * call_hook(JSContext *js, JSStackFrame *fp, JSBool before,
JSBool *ok, void *rb)
static void * call_hook(JSContext *UNUSED(js), JSStackFrame *UNUSED(fp), JSBool before,
JSBool *UNUSED(ok), void *rb)
{
VALUE context = (VALUE)JS_GetContextPrivate(js);
VALUE self = (VALUE)rb;
rb_funcall(self, rb_intern("call_hook"), 1, context);
VALUE rb_before = JS_TRUE == before ? Qtrue : Qfalse;

/* FIXME: Should OK be passed? */
rb_funcall(self, rb_intern("call_hook"), 1, rb_before);
return rb;
}

static void object_hook(JSContext *js, JSObject *obj, JSBool isNew, void *rb)
static void object_hook(JSContext *UNUSED(js), JSObject *UNUSED(obj), JSBool UNUSED(isNew), void *rb)
{
VALUE self = (VALUE)rb;

/* FIXME: Pass this stuff to the debugger. */
rb_funcall(self, rb_intern("object_hook"), 0);
}

static JSTrapStatus throw_hook(JSContext *js, JSScript *script,
jsbytecode *pc, jsval *rval, void *rb)
static JSTrapStatus throw_hook(JSContext *UNUSED(js), JSScript *UNUSED(script),
jsbytecode *UNUSED(pc), jsval *UNUSED(rval), void *rb)
{
VALUE context = (VALUE)JS_GetContextPrivate(js);
VALUE self = (VALUE)rb;
rb_funcall(self, rb_intern("throw_hook"), 1, context);
/* FIXME: Pass this stuff to the debugger? */
rb_funcall(self, rb_intern("throw_hook"), 0);
return JSTRAP_CONTINUE;
}

static JSBool debug_error_hook(JSContext *js, const char *message,
JSErrorReport *report, void *rb)
static JSBool debug_error_hook(JSContext *UNUSED(js), const char *message,
JSErrorReport *UNUSED(report), void *rb)
{
VALUE context = (VALUE)JS_GetContextPrivate(js);
VALUE self = (VALUE)rb;
rb_funcall(self, rb_intern("debug_error_hook"), 1, context);
VALUE rb_message = rb_str_new2(message);
rb_funcall(self, rb_intern("debug_error_hook"), 1, rb_message);
return JS_TRUE;
}

static void deallocate(JSDebugHooks * hooks)
{
//free(hooks);
}

static VALUE allocate(VALUE klass)
{
JSDebugHooks* debug = calloc(1, sizeof(JSDebugHooks));
VALUE self = Data_Wrap_Struct(klass, 0, deallocate, debug);
VALUE self = Data_Wrap_Struct(klass, 0, 0, debug);

debug->interruptHandler = interrupt_handler;
debug->interruptHandlerData = (void *)self;
debug->newScriptHook = new_script_hook;
debug->newScriptHookData = (void *)self;
debug->destroyScriptHook = destroy_script_hook;
debug->destroyScriptHookData = (void *)self;
debug->debuggerHandler = interrupt_handler;
debug->debuggerHandler = debugger_handler;
debug->debuggerHandlerData = (void *)self;
debug->sourceHandler = source_handler;
debug->sourceHandlerData = (void *)self;
Expand Down
35 changes: 15 additions & 20 deletions lib/johnson/spidermonkey/debugger.rb
@@ -1,56 +1,51 @@
require 'dl/struct'

module Johnson #:nodoc:
module SpiderMonkey #:nodoc:
class Debugger # native
# Enum constants from jsprvtd.h
JSTRAP_ERROR = 0
JSTRAP_CONTINUE = 1
JSTRAP_RETURN = 2
JSTRAP_THROW = 3
JSTRAP_LIMIT = 4

attr_accessor :logger
def initialize(logger)
@logger = logger
end

def interrupt_handler(context)
def interrupt_handler
logger.debug("interrupt_handler")
end

def new_script_hook(context)
def new_script_hook
logger.debug("new_script_hook")
end

def destroy_script_hook(context)
def destroy_script_hook
logger.debug("destroy_script_hook")
end

def debugger_handler(context)
def debugger_handler
logger.debug("debugger_handler")
end

def source_handler
logger.debug("source_handler")
def source_handler(filename, line_number)
logger.debug("source_handler: #{filename}(#{line_number})")
end

def execute_hook(context)
logger.debug("execute_hook")
def execute_hook(before)
logger.debug("execute_hook: #{before}")
end

def call_hook(context)
logger.debug("call_hook")
def call_hook(before)
logger.debug("call_hook: #{before}")
end

def object_hook
logger.debug("object_hook")
end

def throw_hook(context)
def throw_hook
logger.debug("throw_hook")
end

def debug_error_hook(context)
logger.debug("debug_error_hook")
def debug_error_hook(message)
logger.debug("debug_error_hook: #{message}")
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/johnson/context_test.rb
Expand Up @@ -5,8 +5,8 @@ module Johnson
class ContextTest < Johnson::TestCase
def setup
@context = Johnson::Context.new
db = Johnson::SpiderMonkey::Debugger.new(Logger.new(STDOUT))
@context.delegate.debugger = db
#db = Johnson::SpiderMonkey::Debugger.new(Logger.new(STDOUT))
#@context.delegate.debugger = db
end

def test_default_delegate_is_spidermonkey
Expand Down

0 comments on commit 9d019b6

Please sign in to comment.