Help On Ruby Integration With C

N

Newb Newb

Hi...

I m using ruby 1.8.6 on Windows..

I m extending Ruby with C.

that is i want to load a DLL into Ruby..

but Ruby fails load my Dll..

i use visual studio.net command Prompt.

I integrate my dll namely prov.dll into C program namely pro1.c

afterthat i call those c functions through ruby .

D:\ruby_extend\pronmake>irb
irb(main):001:0> require 'pro1'
=> true
irb(main):002:0> include Pro
=> Object
irb(main):003:0> Pro::load
=> false
irb(main):004:0>


i get only false..


dll fails to load through ruby...

how can i get the stacktrace ?


Any Advices...


Pls help me out

Thanks

below is my pro1.c code


#include "windows.h"

#include "ruby.h"

#include "pro.h"




#define _D(string) {OutputDebugString(string);}


VALUE Pro;
HINSTANCE hlibrary;




void _textline(const char *s, int len)
//************************************
{
_D(s);
}

static VALUE p_load(VALUE self )
//******************************
{


return pro_load();




}

static VALUE p_init(VALUE self)
//*****************************
{
_D("-> init");

pro_set_textline_callback(_textline);

pro_renderInit();


}

static VALUE p_parse(VALUE self, VALUE string_to_parse)
//*****************************************************
{

_D(StringValuePtr(string_to_parse));
return pro_parse(StringValuePtr(string_to_parse));

}


void proeventcallback(proRenderEventType type, proRenderEventData data)
//************************************************************************
{
switch(type){
case proRenderEventDone:
_D("-> cleanup");
pro_renderCleanUp();
//if (vWindow)
//{
// SendMessage((HWND)NUM2INT(vWindow), WM_USER+2, 0, 0);
//}
}
}

static VALUE pro_render( VALUE self )
//**********************************
{


_D("-> render");

pro_set_renderevent_callback(proeventcallback);
SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_ABOVE_NORMAL);
pro_render(PRO_RENDERASYNC);
return Qtrue;
}


void Init_pro1()
//***************
{

pro = rb_define_module( "Pro" );
rb_define_method(Pro, "load", p_load, 0);
rb_define_method( Pro, "init_engine", p_init, 0 );
rb_define_method(Pro, "parse", p_parse, 1);
rb_define_method(Pro, "render", pr_render, 0);

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top