Never mind. It wouldn't have worked on a 64-bit system anyway because:
static Local<Integer> New(int32_t value);
Anyway, it was funny for a minute or two.
On Sat, Sep 13, 2008 at 12:24 PM, Pete Gontier <[EMAIL PROTECTED]> wrote:
> You mean I don't have to this any more? :-)
>
> struct Compiler
> {
> // Compact, thread-safe way to compile a script and capture the
> line number
> // of the compilation error, if any. Abuses JavaScript Integer
> class to
> // tunnel a pointer through to the callback. Since v8::Integer
> can contain
> // 64-bit values, this should be safe everywhere. Yes, it's true;
> I am
> // pure evil, but only inside these curly braces.
>
> Local <Script> operator ( ) (Handle <String> source, Handle
> <Value>
> fileName, int & lineNumber)
> {
> Local <Integer> lineNumberJS (Integer::New (ptrdiff_t
> (&lineNumber)));
> V8::AddMessageListener
> (CaptureLineNumber,lineNumberJS);
> Local <Script> script (Script::Compile (source,
> fileName));
> V8::RemoveMessageListeners (CaptureLineNumber);
> return script;
> }
>
> private :
>
> static void CaptureLineNumber (Handle <Message> message,
> Handle <Value> value)
> {
> int * lineNumber ((int*) value->ToInteger ( )->Value (
> ));
> *lineNumber = message->GetLineNumber ( );
> }
> };
>
>
> On Tue, Sep 9, 2008 at 11:54 PM, Christian Plesner Hansen
> <[EMAIL PROTECTED]> wrote:
>>
>> You can now get line numbers directly from the TryCatch; see the shell
>> sample for an example of how to use this.
>>
>> On Sep 4, 9:25 pm, "Christian Plesner Hansen"
>> <[EMAIL PROTECTED]> wrote:
>>> I can't test this but as far as I can see from the code that should be
>>> a safe assumption. You may need to SetVerbose on the TryCatch for
>>> this to work properly, otherwise I think the message callback will not
>>> be called.
>>>
>>> On Thu, Sep 4, 2008 at 9:11 PM, Bryan White <[EMAIL PROTECTED]> wrote:
>>>
>>> >> Yes, you can store the Message object in a in a global variable if you
>>> >> hold it in a Persistent handle.
>>>
>>> > That what not my concern. I was asking if it was reasonable to assume
>>> > in the TryCatch handler that the most recent call of the
>>> > MessageCallback was pertinent to the error.
>>>
>>> > --
>>> > Bryan White
>> >>
>>
>
>
>
> --
> Pete Gontier
> http://pete.gontier.org/
>
--
Pete Gontier
http://pete.gontier.org/
--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---