Bug 535200

Summary: bindings for LibStorage::Environment::swig_logdir_set do not work
Product: [openSUSE] openSUSE 11.2 Reporter: Arvin Schnell <aschnell>
Component: YaST2Assignee: Martin Vidner <mvidner>
Status: RESOLVED WONTFIX QA Contact: Jiri Srain <jsrain>
Severity: Normal    
Priority: P3 - Medium CC: jreidinger
Version: Factory   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: Development Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: example script
perl-bindings.patch

Description Arvin Schnell 2009-08-28 15:03:46 UTC
The swig/perl bindings for LibStorage::Environment::swig_logdir_set do not work.
The code

  LibStorage::Environment::swig_logdir_set(env, Directory::logdir);

gives this error:

  Storage.ycp:248 Perl wanted to die: RuntimeError Type error in argument 2 of Environment_logdir_set. Expected a REFERENCE to STRING.

Note: The logdir variable is new in libstorage.
Comment 1 Arvin Schnell 2009-08-31 14:08:53 UTC
Created attachment 315998 [details]
example script
Comment 2 Martin Vidner 2009-08-31 14:44:07 UTC
It's this code in http://svn.opensuse.org/viewvc/yast/trunk/perl-bindings/pluglib-bindings/swig/stl/string.i?revision=57030&view=markup#l30

%typemap(in) std::string* (std::string temp), std::string& (std::string temp),
    const std::string* (std::string temp), const std::string& (std::string temp)
{
    SV *sv;
    if (!SvROK($input) || !(sv = (SV*)SvRV($input)) || !SvPOK(sv) )
        SWIG_croak("Type error in argument $argnum of $symname. Expected a REFERENCE to STRING.\n");

    STRLEN len;
    const char *ptr = SvPV(sv, len);
    if (!ptr)
        SWIG_croak("Undefined variable in argument $argnum of $symname.");
    temp.assign(ptr, len);
    $1 = &temp;
}

Now, the typemap makes a copy of the referenced string anyway, so there is no point in requiring a reference instead of a plain string. I wonder how it can work in the other cases:

$ grep "REFERENCE to STRING" LibStorage_wrap.cc | wc -l
200
Comment 3 Arvin Schnell 2009-12-07 18:31:53 UTC
Any progress here? I need the functionality for the testsuite.
Comment 4 Martin Vidner 2009-12-08 12:37:32 UTC
Sorry no progress (no webyast GM => no surprise).

Can you please check whether the other cases are used and work?
> I wonder how it can work in the other cases:
> $ grep ...
> 200
Comment 5 Arvin Schnell 2009-12-09 17:40:27 UTC
Setting member elements of classes is so far only used for booleans.
Hope that's the information you asked for.
Comment 6 Martin Vidner 2012-03-06 14:14:41 UTC
Created attachment 479749 [details]
perl-bindings.patch

Here's a patch by Pepa submitted in this message:
http://lists.opensuse.org/yast-devel/2012-02/msg00066.html

Thanks, Pepa! I am trying to enable and fix the testsuite along the way.
http://svn.opensuse.org/viewvc/yast?view=revision&revision=67567
Comment 7 Martin Vidner 2016-10-26 11:13:16 UTC
Sorry, we did not get around to fixing this bug.
Judging by the low activity in the item, it seems that this is not a big problem after all, so we close it.
Please reopen if the bug should get fixed.

IIUC we are not using the perl bindings anymore.