| 1 | # Copyright 2010, 2011, 2012, 2014, 2024 Kevin Ryde | ||||||||||
| 2 | |||||||||||
| 3 | # This file is part of Glib-Ex-ObjectBits. | ||||||||||
| 4 | # | ||||||||||
| 5 | # Glib-Ex-ObjectBits is free software; you can redistribute it and/or modify | ||||||||||
| 6 | # it under the terms of the GNU General Public License as published by the | ||||||||||
| 7 | # Free Software Foundation; either version 3, or (at your option) any later | ||||||||||
| 8 | # version. | ||||||||||
| 9 | # | ||||||||||
| 10 | # Glib-Ex-ObjectBits is distributed in the hope that it will be useful, but | ||||||||||
| 11 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||||||||||
| 12 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||||||||||
| 13 | # for more details. | ||||||||||
| 14 | # | ||||||||||
| 15 | # You should have received a copy of the GNU General Public License along | ||||||||||
| 16 | # with Glib-Ex-ObjectBits. If not, see <http://www.gnu.org/licenses/>. | ||||||||||
| 17 | |||||||||||
| 18 | package Glib::Ex::ObjectBits; | ||||||||||
| 19 | 1 | ▶ | use 5.008; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 1 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | |||||||||||
| 24 | # uncomment this to run the ### lines | ||||||||||
| 25 | #use Smart::Comments; | ||||||||||
| 26 | |||||||||||
| 27 | 1 | ▶ | use Exporter; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | 1 | our @ISA = ('Exporter'); | |||||||||
| 29 | 1 | our @EXPORT_OK = qw(set_property_maybe); | |||||||||
| 30 | |||||||||||
| 31 | 1 | our $VERSION = 17; | |||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | sub set_property_maybe { | ||||||||
|
Subroutine
set_property_maybe: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 34 | 0 | my $object = shift; | |||||||||
| 35 | 0 | ▶ | if (@_ & 1) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | 0 | croak "set_property_maybe() expect even number of pname,value arguments"; | |||||||||
| 37 | } | ||||||||||
| 38 | 0 | ▶ | for (my $i = 0; $i < @_; ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | ### set_property_maybe(): $_[$i] | ||||||||||
| 40 | ### pspec(): $object->find_property($_[$i]) | ||||||||||
| 41 | 0 | ▶ | if ($object->find_property($_[$i])) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 0 | $i += 2; | |||||||||
| 43 | } else { | ||||||||||
| 44 | 0 | splice @_, $i, 2; | |||||||||
| 45 | } | ||||||||||
| 46 | } | ||||||||||
| 47 | 0 | $object->set_property (@_); | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | 1 | 1; | |||||||||
| 51 | __END__ | ||||||||||