Skip to content
This repository has been archived by the owner on Mar 7, 2019. It is now read-only.

Inline support #71

Closed
mohawk2 opened this issue Sep 12, 2014 · 8 comments
Closed

Inline support #71

mohawk2 opened this issue Sep 12, 2014 · 8 comments

Comments

@mohawk2
Copy link
Contributor

mohawk2 commented Sep 12, 2014

What do we think of the idea of adding an inheritable Inline function so that it would be possible to do:

package Actual::Module;
use Alien::Subclass qw(Inline);

And then be able to do:

use Inline with => qw(Actual::Module);

Inline will call a class method Actual::Module->Inline, so it's inheritable (that's why I changed it to be a method, not a function). Then it will be easy to use XS with Inline to get the C functions into action.

What say you?

@plicease
Copy link
Contributor

Definitely would like to see this.

  1. I think also add a recipe to the Alien::Base synopsis
  2. How do you plan on testing. Can we make an optional test part of Alien::Base if Inline is installed? Alternative is to have a dist that uses this feature and to track it as part of the release test plan.

@plicease
Copy link
Contributor

When I started looking at this I realize I am not exactly sure what the intended role of Actual::Module is.

The way that I approached this was to add an Inline sub in Alien::Base that returns the appropriate configuration for Inline::C (Question: can we do the same for Inline::CPP? If it is easy then we should do it). This way any Alien::Foo can be used by an Inline module thusly:

use Inline C => 'DATA', with => 'Alien::Foo'; 

if #77 isn't what was intended, please elaborate.

@mohawk2
Copy link
Contributor Author

mohawk2 commented Sep 20, 2014

One slight caveat: you're best off having the with on a separate "use" line: https://metacpan.org/pod/Inline#Playing-with-Others

You may have noted that the ->Inline method checks for which language (C, CPP, etc) it's being called against. This is because you can do this:

use Inline with => qw(Alien::Acme::DontPanic);
use Inline C => 'DATA';
use Inline CPP => 'DATA';

The ->Inline method would get called once each with the arg C and with CPP. So long as you make the method return the right info, and not return an error on CPP, it will just work.

@plicease
Copy link
Contributor

ah okay, that is the way I had it before in the test, I can switch it back.

@plicease
Copy link
Contributor

I believe either #77 or #78 will resolve this feature request. Pending discussion and consensus one of those should be merged.

@plicease
Copy link
Contributor

Should be addressed in 0.005_01

@plicease
Copy link
Contributor

Hrm. I got a failure on 0.005_02 with t/inline.t. I think there was an older version of Inline installed. I think I upgraded unintentionally when installing Inline::CPP and don't know the version that it used to be. If anyone knows if/when the semantics of the with / sub Inline changed we can fix this.

edit or at least skip the test for older Inlines

@plicease
Copy link
Contributor

Nevermind last comment, I believe this is fixed in 0.005_03 (feel free to check my work but).

plicease added a commit that referenced this issue Jul 17, 2017
plicease added a commit that referenced this issue Jul 17, 2017
plicease added a commit that referenced this issue Jul 17, 2017
plicease added a commit that referenced this issue Jul 17, 2017
plicease added a commit that referenced this issue Jul 17, 2017
plicease added a commit that referenced this issue Jul 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants