Marcel,

From: Marcel Grunauer [mailto:[EMAIL PROTECTED]]
> 
> just playing around with Damian's Attribute::Handlers; here's
> *the beginning of* an idea to inline subs directly, using attributes:
[...]
> 
> sub add :C('int', 'int x, int y') {
>          qq{ return x + y; }
> }


How about:

package Inline::Attributes;
use Inline;
use Attribute::Handlers;
sub INLINE :ATTR(CODE,RAWDATA) {
  import Inline *{$_[1]}{NAME} => $_[4], NAME => $_[0]
}
1;
__END__


Which could be used like this:

package MyClass;
use Inline::Attributes;

sub C :INLINE (
  void hello()
  {
    printf("Hello\n"); 
  }
);

&hello;

1;
__END__


This won't work out of the box with the current version of
Attribute::Handlers. Damian would have to patch all his regexes in
Attribute::Handlers to allow to allow multi-line attribute parameters. Which
is easy enough. But I'm assuming it'd work generically for all inline
languages...

Try it out... I believe it should work. I however am still a C ignoramous
and get the following error which I don't understand.

Microsoft (R) Program Maintenance Utility   Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.

"Running Mkbootstrap for build ()"
        C:\Perl\bin\Perl.exe -IC:\Perl\lib -IC:\Perl\lib -MExtUtils::Command
-e chmod 644 build.bs
        C:\Perl\bin\Perl.exe "-IC:\Perl\lib" "-IC:\Perl\lib"
-MExtUtils::Mksymlists  -e "Mksymlists('NAME' => 'build', 'DLBASE' =>
'build', 'DL_FUNCS' => {  }, 'FUNCLIST' => [], 'IMPORTS' => {  }, 'DL_VARS'
=> []);"
        link -out:blib\arch\auto\build\build.dll -dll -nologo -nodefaultlib
-release  -libpath:"C:\Perl\lib\CORE"  -machine:x86 build.obj
C:\Perl\lib\CORE\perl56.lib oldnames.lib kernel32.lib user32.lib gdi32.lib
winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib
netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib  version.lib odbc32.lib
odbccp32.lib msvcrt.lib -def:build.def
LINK : fatal error LNK1181: cannot open input file "build.obj"
NMAKE : fatal error U1077: 'link' : return code '0x49d'
Stop.


Garrett

P.S. If people do like it, and Brian blesses the module name... I'd be happy
to upload this monsterously long and complicated module to CPAN...

Reply via email to