Aleksandar Lazic | 1 May 2007 08:59
Picon
Favicon

Question about embedding and memory handling

Hi,

on another list there was some questions which I can't answer by my self
about neko:

---
> >1) It must always test results of its internal operations, such as
> >  malloc, and return error. lua simply exit()s when memory is over.
> 
> http://www.nekovm.org/doc/ffi#managing_memory

There's no mention how neko tests results in its internals.
---

I think this will be handled by GC but what happens?!

1.) Exceptions
2.) Segfault, I don't think so ;-)
3.) ???

---
> >3) It should support non-blocking oprations, such as
> >
> >   v = get_variable(...)
> >   if (v == NOT_READY) ...
---

I think this could be done with threads but I'am not sure.

The point here is:
(Continue reading)

Nicolas Cannasse | 4 May 2007 12:26
Favicon
Gravatar

Re: Question about embedding and memory handling

> ---
>> >1) It must always test results of its internal operations, such as
>> >  malloc, and return error. lua simply exit()s when memory is over.
>>
>> http://www.nekovm.org/doc/ffi#managing_memory
> 
> There's no mention how neko tests results in its internals.
> ---
> 
> I think this will be handled by GC but what happens?!
> 
> 1.) Exceptions
> 2.) Segfault, I don't think so ;-)
> 3.) ???

In case of out-of-memory, the GC display an error message and then the
VM exits. In case of segfault, the app crashes on windows but for some
signals on Linux (Bus Error) a Neko exception is thrown. This makes
things more easy for debugging.

> ---
>> >3) It should support non-blocking oprations, such as
>> >
>> >   v = get_variable(...)
>> >   if (v == NOT_READY) ...
> ---
> 
> I think this could be done with threads but I'am not sure.

Yes, threads is one possibility. But testing the NOT_READY state can
(Continue reading)

Aleksandar Lazic | 4 May 2007 17:03
Picon
Favicon

Re: Question about embedding and memory handling


On Fre 04.05.2007 12:26, Nicolas Cannasse wrote:
>
>>> >1) It must always test results of its internal operations, such as
>>> >malloc, and return error. lua simply exit()s when memory is over.
>>>
>>> http://www.nekovm.org/doc/ffi#managing_memory
>> 
>> There's no mention how neko tests results in its internals.
>> 
>> I think this will be handled by GC but what happens?!
>> 
>> 1.) Exceptions
>> 2.) Segfault, I don't think so ;-)
>> 3.) ???
>
>In case of out-of-memory, the GC display an error message and then the
>VM exits. In case of segfault, the app crashes on windows but for some
>signals on Linux (Bus Error) a Neko exception is thrown. This makes
>things more easy for debugging.

Which is similar like lua, isn't it?!

Thanks for answers ;-)

BR

Aleks

--

-- 
(Continue reading)

KaalH! | 9 May 2007 11:14
Favicon

mysql multiple queries


hi,

neko cannot handle mysql stored procedures that returns results.
see details here :
http://dev.mysql.com/doc/refman/5.0/en/c-api-multiple-queries.html

here is an ugly hack allowing to handle stored procedures results :

Index: mysql.c
===================================================================
RCS file: /cvsroot/neko/libs/mysql/mysql.c,v
retrieving revision 1.17
diff -u -r1.17 mysql.c
--- mysql.c     9 Jun 2006 10:04:47 -0000       1.17
+++ mysql.c     9 May 2007 09:07:04 -0000
 <at>  <at>  -383,6 +383,7  <at>  <at> 
                else
                        error(MYSQLDATA(o),val_string(r));
        }
+       mysql_next_result(MYSQLDATA(o));
        return alloc_result(res);
 }

 <at>  <at>  -431,7 +432,7  <at>  <at> 
        {
                MYSQL *m = mysql_init(NULL);
                value v;
              if(
mysql_real_connect(m,val_string(host),val_string(user),val_string(pass),NULL,val_int(port),val_is_null(socket)?NULL:val_string(socket),0)
(Continue reading)

Nicolas Cannasse | 10 May 2007 11:47
Favicon
Gravatar

Re: mysql multiple queries

> hi,
> 
> neko cannot handle mysql stored procedures that returns results.
> see details here :
> http://dev.mysql.com/doc/refman/5.0/en/c-api-multiple-queries.html
> 
> here is an ugly hack allowing to handle stored procedures results :

The problem of defining CLIENT_MULTI_STATEMENTS by default is that it
opens a big hole for SQL injection.

Are there no other ways to do that ? Maybe adding a method
enable_stored_procedures(cnx) would be better ?

Nicolas

--

-- 
Neko : One VM to run them all
(http://nekovm.org)

Itamar Rauch | 11 May 2007 12:17
Picon

neko.lib and VC8

Hello everyone,

This is my first post ever in this list so I thought I'd start out with a hearty hello, so... Hello :)
I'm a C++ programmer interested in some of neko's cool features, in order to help a friend run his flash game in fullscreen with the option to change resolution. (At this point, if anyone knows how to do it straight through neko without using a C++ compiled ndll I'd love to hear about it)
Anyways, I'm using Microsoft's VC8 and I tried compiling the C FFI tutorial's primitive example using VC8, and here's my experience from it:
I created a C++ console application, marked it to generate a DLL configuration, so now I've got a blank DLL project, with DLLMain(). This, of course, compiles without errors. Then I link the neko.lib in the project, and the compilation fails on linkage to C:\Program.obj, saying there's no such file. I tried playing around with the project's linking configurations to no use. I later tried compiling the .cpp file using the command line compiler, again it fails.

After googling for a while, I came across some of this group's mails, saying someone compiled it under VC7.1 without errors. So I gave that a go, and indeed it works! I followed the same basic steps, of creating a simple blank DLL and linking the neko.lib, and it just works.
I'm guessing that's not really breaking news, but I couldn't take a chance that there's someone else out there, banging his head against the wall since neko doesn't compile with his VC8 :)
And other than that, I think Nicolas, or someone else should know about it. Maybe it's something about the way neko.lib was compiled? I don't know... I'm just glad it works now :)

Onwards! To making neko run openGL! :)

--

-- 
Neko : One VM to run them all
(http://nekovm.org)
Mark Winterhalder | 11 May 2007 13:27
Picon

Re: neko.lib and VC8

On 5/11/07, Itamar Rauch <donjim <at> gmail.com> wrote:
> Onwards! To making neko run openGL! :)

<http://xinf.org/trac/wiki/NekoOpenGL>

Regarding the screen resolution...:
<http://code.google.com/p/neko-systools/>
...specifically:
<http://tinyurl.com/33gxzk>

HTH,
Mark

--

-- 
Neko : One VM to run them all
(http://nekovm.org)

Nicolas Cannasse | 11 May 2007 14:01
Favicon
Gravatar

Re: neko.lib and VC8

> Then I link the neko.lib in
> the project, and the compilation fails on linkage to C:\Program.obj,
> saying there's no such file. 

I would say that it looks like a space in a path is causing some trouble.

Nicolas

--

-- 
Neko : One VM to run them all
(http://nekovm.org)

Itamar Rauch | 11 May 2007 15:05
Picon

Re: neko.lib and VC8

I feel like such a fool, it was actually missing the quotation marks around the lib file path! Thanks :)

> < http://xinf.org/trac/wiki/NekoOpenGL>
>
> Regarding the screen resolution...:
> < http://code.google.com/p/neko-systools/>
> ...specifically:
> <http://tinyurl.com/33gxzk >

Thanks a lot mark! This has been most helpful! You saved me a lot of work :)
I'm having troubles though with the flash window not getting the keyboard and mouse events. I figured I can try to use the
swhx.Connection.flashConnect(flash)
object returned here, and then overload the windows' events (in haxe code) to call Flash commands via functions I'll declare for that purpose. But my guess is there's a better way to do it, can anyone help here?



On 5/11/07, Nicolas Cannasse <ncannasse <at> motion-twin.com > wrote:
> Then I link the neko.lib in
> the project, and the compilation fails on linkage to C:\Program.obj,
> saying there's no such file.

I would say that it looks like a space in a path is causing some trouble.

Nicolas

--
Neko : One VM to run them all
(http://nekovm.org )

--

-- 
Neko : One VM to run them all
(http://nekovm.org)
blackdog | 14 May 2007 15:30
Gravatar

Noobie Question re memory


Hi Nicholas

First, neko is awesome, i'm finding the FFI very intuitive to use.
Thanks for such great software.

I'm attempting to wrap Gtk in neko for use in haxe and so far it's
going quite well, but my first question is

value labelSetText(value w,value l) {
	val_check_kind(w,k_label);
	val_check(l,string);
	gtk_label_set_text(GTK_LABEL(val_data(w)),val_string(l));
	return val_true;
}

when I dereference val_string(l) do i get a copy of the string or is it
still garbage collected? I don't want to be passing a garbage collected
string to Gtk, so should I strdup(val_string(l)) ?

And I've come across a bizarre problem with the function above, I call
it with

	private function setLabel(l:String) { _setLabel(_object,l);
return l; }

and define it with 

	static var _setLabel = neko.Lib.load("test","labelSetText",2);

now all the other functions I've wrapped require _setX(_object,untyped
l.__s) but this one fails with the following error

       Uncaught exception - Invalid field access : __s

but it does work fine as defined above. So the bizarreness is
inconsistency.

Thx

bd

-- 
"It is no measure of health to be well adjusted to a profoundly sick
society." --Jiddu Krishnamurti

--

-- 
Neko : One VM to run them all
(http://nekovm.org)


Gmane