deltaluca / nape

Haxe/AS3 Physics Engine
http://napephys.com
Other
542 stars 77 forks source link

Difference in observed and actual API w.r.t. optional arguments in compiled libraries #1

Closed profelis closed 12 years ago

profelis commented 13 years ago
  1. AS3 project 2.

ray = new Ray(); //public function Ray (origin:Vec2=null, direction:Vec2=null); // swc ray interface

[Fault] exception, information=Error: Ray::origin cannot be null

deltaluca commented 13 years ago

Unfortunately i'm not entirely sure if this can be resolved entirely.

The actual source code for nape would show that origin and direction are 'not' optional arguments. they become optional when compiled by haxe into the .swf/.swc; most likely for reflection purposes. If it did not break the library I could modify my .swc tool to remove such optional parameters though i can't think of an easy way to actually distinguish between a fake-optional like this, and a real optional which happens to have it's default value as null.

Perhaps for static libary compilation I can find a hack; or perhaps add some metadata that my tool can read to denote real optinoal parameters from normal ones though that would require a bit of work to add all of it into the source! :P

profelis commented 13 years ago

I did not know what the problem is so deep :) I've seen something similar in Space constructor and there you are all corrected quickly (this is my issue http://deltaluca.me.uk/forum/index.php/t/227/9f501d6ea295bca663bb63f214c5c115/ )

I suggest to change issue status from 'bug' to 'feature request' :)

deltaluca commented 13 years ago

I'm going to take a look this evening and see what could be done about this in future

deltaluca commented 12 years ago

Checking this further now, the issue seems confined to class constructors only, which is a very good thing! any extra metadata can be similarly confined to have flib remove optionals

deltaluca commented 12 years ago

Done.