Re: Comments on ORAC

new topic     » goto parent     » topic index » view thread      » older message » newer message

Matt Lewis wrote:
> 
> I think you're overcomplicating this.  Since you're writing a preprocessor,
> you just need to create a global function and a global procedure, something
> like:
> }}}
<eucode>
> global function call_indirect_function( integer func, sequence args )
>     if and_bits( func, C_FUNC_INDIRECT ) then
>         return c_func( and_bits( func, ROUTINE_MASK ), args )
> 
>     elsif and_bits( func, EU_FUNC_INDIRECT ) then
>         return call_func( and_bits( func, ROUTINEMASK ), args )
>     end if
>     -- error handling here...
> end function
> </eucode>
{{{

> 
Yep, that is what I meant. I also knew that the work Mike has just done allows
eg constant r_id=routine_id("eu_func") ... call_func(r_id,{}), when there was no
other use of r_id, to be left as-is, so I let him get on with that part first.
But if r_id gets used elsewhere, ie stored in some larger structure, esp a mix of
eu/c func/proc, then:
r_id = define_c_func(blah)
  ...
     s[j] = {r_id,x,y,z}
  ...
  s[k].1(blahblah)   -- a "void = " may be needed(/autoinserted) here
  ...
  void = c_func(r_id,blah3)

==>
r_id = or_bits(define_c_func(blah),CFUNC)
  ...
     s[j] = {r_id,x,y,z}
  ...
  orac_proc(s[k].1,blahblah)
  ...
  void = c_func(and_bits(r_id,MASK),blah3)

where orac_proc is the sister routine of the one Matt just posted:
global procedure orac_proc(integer id, object args)
integer isFunc, isC

  isFunc = and_bits(id, FUNCTION)
  isC = and_bits(id, CCALL)
  id = and_bits(id, MASK)

  if isFunc then
      if isC then
          void = c_func(id,args)
      else
          void = call_func(id,args)
      end if
  else
      if isC then
          c_proc(id,args)
      else
          call_proc(id,args)
      end if
  end if
end procedure

By all means avoid using such wrappers when you possibly can.

I also believe it would be quite trivial to (later) change the back end to set
such bits in define_c_func/proc & routine_id, and completely ignore them in
call_/c_ func/proc. At the last minute I changed a "+CFUNC" above to or_bits() to
ease this. All existing code should work unaltered, unless doing something very
strange like call_func(r_id+1,{}), and even that would probably still work in
most cases.

Regards,
Pete

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu