This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: some questions using callbacks to java


Help, we are losing our minds. We are doing something like this to set
variables inside the scheme environment using a callback. Here's an example:

public void get_string_characteristic ( String keyColumn, String keyValue,
                                        String characteristicName ) {

        // This is returning a String object that was extracted from a
        // database using JDBC.

        Object result = get_one_characteristic (keyColumn, keyValue,
characteristicName );
        
        if (result instanceof String) {
            e . put ( characteristicName,
                new gnu.kawa.util.FString ( (String) result )
            );
        }
    }

After the put() executes, we seem to have a binding in the environment. We
execute the above using a call back:

(invoke database-callbacks 'get_string_characteristic "ID" "1" 'Gender)
                
(invoke debug-callbacks 'print Gender)

** the result is Male
                
(invoke debug-callbacks 'print (or (equal? Gender "Male") (equal? Gender
"Female")))

*** the result is false

(invoke debug-callbacks 'print (equal? Gender "Male"))

*** the result is false but it should be true

(invoke debug-callbacks 'print (equal? Gender "Female"))
(invoke debug-callbacks 'print (eq? Gender "Male"))
(invoke debug-callbacks 'print (eq? Gender "Female"))
(invoke debug-callbacks 'print (equal? Gender 'Male))
(invoke debug-callbacks 'print (equal? Gender 'Female))

*** the above all return false

(invoke debug-callbacks 'print (invoke (invoke Gender 'getClass) 'getName ))

*** this returns gnu.kawa.util.FString, as expected.

The question is, what is wrong with this binding? It seems to have the right
type and value but doesn't evaluate correctly the way we expect. We have a
similar problem here:

(invoke parameter-callbacks 'bind 'PT_ID)
(invoke debug-callbacks 'print PT_ID)

which boils down to

public void bind ( String paramName ) {
    ...
    Object result = e . put ( paramName, param );
}

(invoke parameter-callbacks 'bind 'PT_ID)
(invoke debug-callbacks 'print PT_ID)

*** prints 1

(invoke debug-callbacks 'print (equal? PT_ID "1"))

*** prints false

(invoke debug-callbacks 'print (invoke (invoke PT_ID 'getClass) 'getName ))

*** prints java.lang.String

and again we have a value which prints correctly but can't be evaluated in
an expression.

So the question is, how can we make this work? We're comparing FStrings to
Kawa strings, which doesn't work and we're comparing Java strings to Kawa
strings and that doesn't work. We've also tried to pass string.intern() to
put() but I thought intern() wasn't necessary anymore -- but in any case, it
doesn't seem to help.

Thanks very much for your help.
-- 
Paul Potts and Mike Nowak.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]