public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* ImagJ/Fiji 'binding' wrong number of args - help welcome
@ 2018-01-21  1:00 David Pirotte
  2018-01-21  7:12 ` Per Bothner
  0 siblings, 1 reply; 5+ messages in thread
From: David Pirotte @ 2018-01-21  1:00 UTC (permalink / raw)
  To: kawa

[-- Attachment #1: Type: text/plain, Size: 1082 bytes --]

Hello,

I'm trying to provide access to an ImageJ/Fiji plugin defined here [1]. To start
with, I want to 'bind' processImage (see line 116 in [1], like this:

  (define-alias process-image
    sc.fiji.localThickness.LocalThicknessWrapper:processImage)

then:

  export CLASSPATH=.:./jars/ij.jar:./jars/local-thickness.jar
  kawa -C ij-local-thickness.scm

but when I try:

  kawa -Dplugins.dir=/usr/lpdi/projects/kawa/jars
  #|kawa:1|# (import (ij-core)
          (ij-local-thickness))
  #|.....2|# #|kawa:3|# (define iplus1 (ij-open "images/camada-mapa.png"))
  #|kawa:4|# (ij-local-thickness iplus1)
  gnu.mapping.WrongArguments: call to 'sc.fiji.localThickness.LocalThicknessWrapper.processImage(ij.ImagePlus)' has too few arguments (1; must be 2)
	at gnu.mapping.CallContext.matchError(CallContext.java:150)
	at gnu.expr.PrimProcedure.applyToConsumerX(PrimProcedure.java:196)
        ...

What am I doing wrong?

Thanks,
David

[1] https://github.com/fiji/LocalThickness/blob/master/src/main/java/sc/fiji/localThickness/LocalThicknessWrapper.java

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: ImagJ/Fiji 'binding' wrong number of args - help welcome
  2018-01-21  1:00 ImagJ/Fiji 'binding' wrong number of args - help welcome David Pirotte
@ 2018-01-21  7:12 ` Per Bothner
  2018-01-21  8:59   ` David Pirotte
  0 siblings, 1 reply; 5+ messages in thread
From: Per Bothner @ 2018-01-21  7:12 UTC (permalink / raw)
  To: David Pirotte, kawa

On 01/20/2018 04:59 PM, David Pirotte wrote:
> but when I try:
> 
>    kawa -Dplugins.dir=/usr/lpdi/projects/kawa/jars
>    #|kawa:1|# (import (ij-core)
>            (ij-local-thickness))
>    #|.....2|# #|kawa:3|# (define iplus1 (ij-open "images/camada-mapa.png"))
>    #|kawa:4|# (ij-local-thickness iplus1)
>    gnu.mapping.WrongArguments: call to 'sc.fiji.localThickness.LocalThicknessWrapper.processImage(ij.ImagePlus)' has too few arguments (1; must be 2)
> 	at gnu.mapping.CallContext.matchError(CallContext.java:150)
> 	at gnu.expr.PrimProcedure.applyToConsumerX(PrimProcedure.java:196)
>          ...
> 
> What am I doing wrong?

processImage is a non-static method, so it needs two arguments:
The implicit 'this' argument, plus the inputImage argument.

-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: ImagJ/Fiji 'binding' wrong number of args - help welcome
  2018-01-21  7:12 ` Per Bothner
@ 2018-01-21  8:59   ` David Pirotte
  2018-01-21 18:42     ` Per Bothner
  0 siblings, 1 reply; 5+ messages in thread
From: David Pirotte @ 2018-01-21  8:59 UTC (permalink / raw)
  To: Per Bothner; +Cc: kawa

[-- Attachment #1: Type: text/plain, Size: 847 bytes --]

Hello Per,

> >    kawa -Dplugins.dir=/usr/lpdi/projects/kawa/jars
> >    #|kawa:1|# (import (ij-core)
> >            (ij-local-thickness))
> >    #|.....2|# #|kawa:3|# (define iplus1 (ij-open "images/camada-mapa.png"))
> >    #|kawa:4|# (ij-local-thickness iplus1)
> >    gnu.mapping.WrongArguments: call to
> > 'sc.fiji.localThickness.LocalThicknessWrapper.processImage(ij.ImagePlus)' has
> > too few arguments (1; must be 2) at
> > gnu.mapping.CallContext.matchError(CallContext.java:150) at
> > gnu.expr.PrimProcedure.applyToConsumerX(PrimProcedure.java:196) ...
> > 
> > What am I doing wrong?  
> 
> processImage is a non-static method, so it needs two arguments:
> The implicit 'this' argument, plus the inputImage argument.
> 

But what is 'this' argument, how do I 'grab it' from imagej/fiji plugin?

thanks,
David

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: ImagJ/Fiji 'binding' wrong number of args - help welcome
  2018-01-21  8:59   ` David Pirotte
@ 2018-01-21 18:42     ` Per Bothner
  2018-01-22  1:49       ` David Pirotte
  0 siblings, 1 reply; 5+ messages in thread
From: Per Bothner @ 2018-01-21 18:42 UTC (permalink / raw)
  To: David Pirotte; +Cc: kawa

On 01/21/2018 12:58 AM, David Pirotte wrote:

> But what is 'this' argument, how do I 'grab it' from imagej/fiji plugin?

That is not a question about Kawa.  It is a question about the imagej/fiji plugin.
How would you get the 'this' argument in a Java program? Somewhere in the
library or code that uses it there is a call 'new MaskThicknessMapWithOriginalTest'.
That result is what you need to pass to as the 'this' parameter.

If you want to write a Kawa wrapper for a Java plugin, you need to understand the
Java API - and how you would use the pluin in a Java application.  You then have the
option of designing a Kawa API that feels very different from the Java API - or
you can just use the "thin wraper" that Kawa gives you automatically.  Regardless,
you have to understand the Java API before you either use it directly or design
a Kawa library on top of it.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: ImagJ/Fiji 'binding' wrong number of args - help welcome
  2018-01-21 18:42     ` Per Bothner
@ 2018-01-22  1:49       ` David Pirotte
  0 siblings, 0 replies; 5+ messages in thread
From: David Pirotte @ 2018-01-22  1:49 UTC (permalink / raw)
  To: Per Bothner; +Cc: kawa

[-- Attachment #1: Type: text/plain, Size: 870 bytes --]

Hello Per,

> > But what is 'this' argument, how do I 'grab it' from imagej/fiji plugin?  

> That is not a question about Kawa.  It is a question about the imagej/fiji plugin.
> How would you get the 'this' argument in a Java program?
> ...

I actually figured it out before to read your 2nd email, but of course thanks a lot
for your answers, and, yes, a java related quizz, plus how to implemented it in
kawa...

It would have been a lot more productive though, if you allow me, to answer (your
first answer) something like [*]

	... these methods always expect, as their first _implicit_ argument, an
	instance of the class that 'holds' the methods [*]. so in this case:

	(define-alias ltw-new sc.fiji.localThickness.LocalThicknessWrapper:new)

	(process-image (ltw-ew) iplus)

Cheers,
David

[*] 	'this' really didn't mean anything to me

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-01-22  1:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-21  1:00 ImagJ/Fiji 'binding' wrong number of args - help welcome David Pirotte
2018-01-21  7:12 ` Per Bothner
2018-01-21  8:59   ` David Pirotte
2018-01-21 18:42     ` Per Bothner
2018-01-22  1:49       ` David Pirotte

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).