Soren,

Thank you for your fast answer! :-)

First, let me say that you guys are starting a Revolution! Web 3.0 is
coming powered by v8 and Chrome!... :-D

Back to the dll...

Before trying to compile the v8 dll I built a wrapper dll with just
one function but the Delphi app that uses the dll throws an exception
when it allocates the handle scope. I have no clue why.

The function is very simple. It is inspired by the 'getting started'
demo and compiles fine in VC++ and runs fine. I've put some debugging
text in it. You will find at the end of the post.

When it gets to the line 'HandleScope handle_scope;' the Delphi .exe
throws the exception. In other words the debugging text "HANDLESCOPE"
never gets displayed.

The exception is: "InvalidOp. Invalid floating point operation.".

Thanks in advance! :-)

Hoch.

-----------------------------------------------------------------

## dll header
extern "C" __declspec(dllexport) int TestV8();

## dll function
int TestV8 () {
  char dumb[1];

  std::cout << "START";
  scanf(dumb);

  // Create a stack-allocated handle scope.
  HandleScope handle_scope;
  std::cout << "HANDLESCOPE";
  scanf(dumb);

  // Create a new context.
  Handle<Context> context = Context::New();
  std::cout << "CREATE CONTEXT";
  scanf(dumb);

  // Enter the created context for compiling and
  // running the hello world script.
  Context::Scope context_scope(context);
  std::cout << "ENTER CONTEXT";

  // Create a string containing the JavaScript source code.
  Handle<String> source = String::New("a = '2 + 2 = ' + (2 + 2);");
  std::cout << "CREATE STRING WITH JS";

  // Compile the source code.
  Handle<Script> script = Script::Compile(source);
  std::cout << "COMPILE";

  // Run the script to get the result.
  TryCatch trycatch;
  Handle<Value> result = script->Run();
  std::cout << "RUN";

  // Convert the result to an ASCII string and print it.
  if (result.IsEmpty()) {
    //ReportException(&trycatch);
    Handle<Value> exception = trycatch.Exception();
    String::AsciiValue exception_str(exception);
    std::cout << *exception_str;
   }
  else
  {
    String::AsciiValue ascii(result);
    std::cout << *ascii;
  };

  return 0;
}

On Sep 22, 2:17 pm, "Søren Gjesse" <[EMAIL PROTECTED]> wrote:
> The V8 API is a C++ interface which on Windows is exported to the DLL
> using __declspec(dllexport). When an application is build the C++ interface
> is imported using __declspec(dllimport). This woks fine when Microsoft C++
> is used for compiling both the DLL and the application using the DLL as the
> same name mangling (name decoration) scheme used by both the generator of
> the DLL and the application using it 
> (seehttp://msdn.microsoft.com/en-us/library/56h2zst2(VS.80).aspx).<http://msdn.microsoft.com/en-us/library/56h2zst2(VS.80).aspx>
> Also note that with the current design of the API parts of the API code will
> reside in the application and not in the DLL. Look for the use of
> EXPORT_INLINE in include/v8.h.
>
> To use the V8 DLL from an application not build by Microsoft C++ will
> require another API layer written using a plain C interface.
>
> The same goes for the Linux shared library where the conpiler building the
> libv8.so and the compiler using it will both have to be C++ compilers using
> the same name mangling scheme (this has only been tested with g++).
>
> Regards,
> Søren
>
> On Sun, Sep 21, 2008 at 4:05 PM, Hoch <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I just compiled v8 as DLL and I have problems with the decorated text
> > in the 433 entries in the DLL.
>
> > I did a DUMPBIN and the entries look like this (just the 4 first
> > entries):
>
> > ----------------------------------------------------------------------
> > File Type: DLL
>
> >  Section contains the following exports for v8.dll
>
> >    00000000 characteristics
> >    48D6225A time date stamp Sun Sep 21 12:30:50 2008
> >        0.00 version
> >           1 ordinal base
> >         433 number of functions
> >         433 number of names
>
> >    ordinal hint RVA      name
> > C:\Descargas\V8\src
> >          1    0 00003E30 ??0?
> > [EMAIL PROTECTED]@v8@@@v8@@[EMAIL PROTECTED]@1@@Z = ??0?
> > [EMAIL PROTECTED]@v8@@@v8@@[EMAIL PROTECTED]@1@@Z (public: __thiscall
> > v8::Handle<class v8::Int32>::Handle<class v8::Int32>(class v8::Int32
> > *))
> >          2    1 0000B0A0 [EMAIL PROTECTED]@v8@@@v8@@[EMAIL PROTECTED] = ??0?
> > [EMAIL PROTECTED]@v8@@@v8@@[EMAIL PROTECTED] (public: __thiscall 
> > v8::Handle<class
> > v8::Integer>::Handle<class v8::Integer>(void))
> >          3    2 00003E30 ??0?
> > [EMAIL PROTECTED]@v8@@@v8@@[EMAIL PROTECTED]@1@@Z = ??0?
> > [EMAIL PROTECTED]@v8@@@v8@@[EMAIL PROTECTED]@1@@Z (public: __thiscall
> > v8::Handle<class v8::Int32>::Handle<class v8::Int32>(class v8::Int32
> > *))
> >          4    3 0000B0A0 [EMAIL PROTECTED]@v8@@@v8@@[EMAIL PROTECTED] = ??0?
> > [EMAIL PROTECTED]@v8@@@v8@@[EMAIL PROTECTED] (public: __thiscall 
> > v8::Handle<class
> > v8::Integer>::Handle<class v8::Integer>(void))
> > ........
> > ---------------------------------------------------------
>
> > Is there a way to compile the project so that the names are more
> > accessible?
> > I'm trying to use the dll with Delphi.
>
> > How are other people doing this?
>
> > And why the lib file is 13MB and the DLL only 1.2MB?
>
> > Thank you in advance! :-)
>
> > Hoch Martínez
--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to