MOO-cows Mailing List Archive
[Prev][Next][Index][Thread]
Re: register_function line
On Wed, 29 May 1996, H. Peter Anvin wrote:
> Followup to: <Pine.LNX.3.91.960529192149.494A-100000@ralin.mistral.co.uk>
> By author: bartmoss@mistral.co.uk
> In newsgroup: local.moo
> >
> > > float bf_distance(float stop[3], float start[3])
> >
> > The register line looked fine, did you notice that
> > arglist.v.list[i].v.fnum was a pointer?
> >
>
> More importantly, the calling convention for a builtin function is:
>
> static package
> bf_functionname(Var arglist, Byte next, void *vdata, Objid progr)
> {
> ...
> }
>
> In your case you have not only to unroll the arglist (which is a
> variable which is always a list) but also check the constitution of
> the component lists (since that is not done automatically).
>
> Completely untested top-of-my-head code:
>
> static package
> bf_distance(Var arglist, Byte next, void *vdata, Objid progr)
> {
> double stop[3], start[3], *dp, dist;
> Var r;
> int i, j;
>
> for ( i = 1 ; i <= 2 ; i++ )
> {
> dp = (i==1) ? stop : start;
>
> r = arglist.v.list[i];
> if (r.v.list[0].num != 3)
> {
> free_var(arglist);
> return make_error_pack(E_INVARG);
> }
>
> for ( j = 1 ; i <= 3 ; i++ )
> {
> if ( r.v.list[j].type != TYPE_FLOAT )
> {
> free_var(arglist);
> return make_error_pack(E_INVARG);
> }
> dp[j-1] = *r.v.list[j].v.fnum;
> }
> }
>
> /* Do your thing, for example... */
>
> dist = 0.0;
> for ( i = 0 ; i < 3 ; i++ )
>
****** Wouldn't I need a { here?
> dist += (start[i]-stop[i])*(start[i]-stop[i]);
And } here?
> dist = sqrt(dist);
>
> return make_var_pack(new_float(dist));
> }
extensions.c: In function `bf_distance':
extensions.c:190: structure has no member named `num'
extensions.c:210: warning: implicit declaration of function `newfloat'
extensions.c:211: incompatible type for argument 1 of `make_var_pack'
*** Error code 1
Then it stopped...What's wrong with it?
ALSO: When I compiled another MOO, the version of GCC didn't support the '-g'
option. I got hundreds of warnings - I mean lots of 'em. It still
compiled and is running fine so far, but will this have any effect on the
moo's operation or anything else? Is there a way around it (besides getting
a new version of GCC, of which I have no control over)?
Thanks again.
Follow-Ups:
References:
Home |
Subject Index |
Thread Index