Cairo-1.109/ 000755 001750 000024 00000000000 14001743452 013012 5 ustar 00brian staff 000000 000000 Cairo-1.109/cairo-perl-private.h 000644 001750 000024 00000002300 11664406567 016702 0 ustar 00brian staff 000000 000000 /*
* Copyright (c) 2004-2005 by the cairo perl team (see the file README)
*
* Licensed under the LGPL, see LICENSE file for more information.
*
* $Id$
*
*/
#ifndef _CAIRO_PERL_PRIVATE_H_
#define _CAIRO_PERL_PRIVATE_H_
#include "ppport.h"
void * cairo_perl_alloc_temp (int nbytes);
void cairo_perl_set_isa (const char * child_package, const char * parent_package);
cairo_matrix_t * cairo_perl_copy_matrix (cairo_matrix_t *matrix);
#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
void cairo_perl_package_table_insert (void *pointer, const char *package);
const char * cairo_perl_package_table_lookup (void *pointer);
#endif
#define CAIRO_PERL_CHECK_STATUS(status) \
if (CAIRO_STATUS_SUCCESS != status) { \
SV *errsv = get_sv ("@", TRUE); \
sv_setsv (errsv, newSVCairoStatus (status)); \
croak (Nullch); \
}
cairo_bool_t cairo_perl_sv_is_defined (SV *sv);
#define cairo_perl_sv_is_ref(sv) \
(cairo_perl_sv_is_defined (sv) && SvROK (sv))
#define cairo_perl_sv_is_array_ref(sv) \
(cairo_perl_sv_is_ref (sv) && SvTYPE (SvRV(sv)) == SVt_PVAV)
#define cairo_perl_sv_is_hash_ref(sv) \
(cairo_perl_sv_is_ref (sv) && SvTYPE (SvRV(sv)) == SVt_PVHV)
#endif /* _CAIRO_PERL_PRIVATE_H_ */
Cairo-1.109/perl-cairo.doap 000644 001750 000024 00000001432 13544006551 015717 0 ustar 00brian staff 000000 000000
Cairo
Perl interface to the cairo 2d vector graphics library
Torsten Schönfeld
tsch
Cairo-1.109/CairoFt.xs 000644 001750 000024 00000002522 11664366475 014740 0 ustar 00brian staff 000000 000000 /*
* Copyright (c) 2007 by the cairo perl team (see the file README)
*
* Licensed under the LGPL, see LICENSE file for more information.
*
* $Id$
*/
#include
#include
static const cairo_user_data_key_t face_key;
static void
face_destroy (void *face)
{
SvREFCNT_dec ((SV *) face);
}
MODULE = Cairo::Ft PACKAGE = Cairo::FtFontFace PREFIX = cairo_ft_font_face_
BOOT:
cairo_perl_set_isa ("Cairo::FtFontFace", "Cairo::FontFace");
# cairo_font_face_t * cairo_ft_font_face_create_for_ft_face (FT_Face face, int load_flags);
cairo_font_face_t_noinc *
cairo_ft_font_face_create (class, SV *face, int load_flags=0)
PREINIT:
FT_Face real_face = NULL;
cairo_status_t status;
CODE:
if (sv_isobject (face) && sv_derived_from (face, "Font::FreeType::Face")) {
real_face = (FT_Face) SvIV ((SV *) SvRV (face));
} else {
croak("'%s' is not of type Font::FreeType::Face",
SvPV_nolen (face));
}
RETVAL = cairo_ft_font_face_create_for_ft_face (real_face, load_flags);
/* Keep the face SV (and thus the FT_Face) alive long enough */
SvREFCNT_inc (face);
status = cairo_font_face_set_user_data (RETVAL, &face_key, face,
face_destroy);
if (status) {
warn ("Couldn't install a user data handler, "
"so an FT_Face will be leaked");
}
OUTPUT:
RETVAL
Cairo-1.109/cairo-perl.typemap 000644 001750 000024 00000002432 11747045545 016465 0 ustar 00brian staff 000000 000000 #
# Copyright (c) 2004-2012 by the cairo perl team (see the file README)
#
# Licensed under the LGPL, see LICENSE file for more information.
#
TYPEMAP
# For backwards compatibility: The typemap shipped with perl 5.6.2 apparently
# don't know const char *.
const char * T_PV
char_utf8 * T_PV_UTF8
const char_utf8 * T_PV_UTF8
cairo_bool_t T_UV
cairo_font_extents_t * T_CAIRO_FONT_EXTENTS
cairo_text_extents_t * T_CAIRO_TEXT_EXTENTS
cairo_glyph_t * T_CAIRO_GLYPH
cairo_text_cluster_t * T_CAIRO_TEXT_CLUSTER
cairo_path_t * T_CAIRO_PATH
FT_Face T_FT_FACE
# -----------------------------------------------------------------------------
INPUT
T_PV_UTF8
sv_utf8_upgrade ($arg);
$var = ($type) SvPV_nolen ($arg);
T_CAIRO_GLYPH
$var = SvCairoGlyph ($arg);
T_CAIRO_TEXT_CLUSTER
$var = SvCairoTextCluster ($arg);
T_CAIRO_PATH
$var = SvCairoPath ($arg);
# -----------------------------------------------------------------------------
OUTPUT
T_PV_UTF8
sv_setpv ((SV*)$arg, $var);
SvUTF8_on ($arg);
T_CAIRO_FONT_EXTENTS
$arg = newSVCairoFontExtents ($var);
T_CAIRO_TEXT_EXTENTS
$arg = newSVCairoTextExtents ($var);
T_CAIRO_GLYPH
$arg = newSVCairoGlyph ($var);
T_CAIRO_TEXT_CLUSTER
$arg = newSVCairoTextCluster ($var);
T_CAIRO_PATH
$arg = newSVCairoPath ($var);
Cairo-1.109/inc/ 000755 001750 000024 00000000000 14001743452 013563 5 ustar 00brian staff 000000 000000 Cairo-1.109/LICENSE 000644 001750 000024 00000063500 11706206434 014026 0 ustar 00brian staff 000000 000000 GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms of the
ordinary General Public License).
To apply these terms, attach the following notices to the library. It is
safest to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
Copyright (C)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
Also add information on how to contact you by electronic and paper mail.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!
Cairo-1.109/CairoFont.xs 000644 001750 000024 00000023423 11747045545 015272 0 ustar 00brian staff 000000 000000 /*
* Copyright (c) 2004-2005, 2012 by the cairo perl team (see the file README)
*
* Licensed under the LGPL, see LICENSE file for more information.
*
* $Id$
*/
#include
#include
static const char *
get_package (cairo_font_face_t *face)
{
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_font_type_t type;
const char *package;
type = cairo_font_face_get_type (face);
switch (type) {
case CAIRO_FONT_TYPE_TOY:
package = "Cairo::ToyFontFace";
break;
case CAIRO_FONT_TYPE_FT:
package = "Cairo::FtFontFace";
break;
/* These aren't wrapped yet: */
case CAIRO_FONT_TYPE_WIN32:
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0)
case CAIRO_FONT_TYPE_QUARTZ:
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 8, 0)
case CAIRO_FONT_TYPE_USER:
#endif
package = "Cairo::FontFace";
break;
default:
warn ("unknown font face type %d encountered", type);
package = "Cairo::FontFace";
break;
}
return package;
#else
const char *package = cairo_perl_package_table_lookup (face);
return package ? package : "Cairo::FontFace";
#endif
}
SV *
cairo_font_face_to_sv (cairo_font_face_t *face)
{
SV *sv = newSV (0);
sv_setref_pv(sv, get_package (face), face);
return sv;
}
/* ------------------------------------------------------------------------- */
MODULE = Cairo::Font PACKAGE = Cairo::FontFace PREFIX = cairo_font_face_
cairo_status_t cairo_font_face_status (cairo_font_face_t * font);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_font_type_t cairo_font_face_get_type (cairo_font_face_t *font_face);
#endif
void DESTROY (cairo_font_face_t * font)
CODE:
cairo_font_face_destroy (font);
# --------------------------------------------------------------------------- #
MODULE = Cairo PACKAGE = Cairo::ToyFontFace PREFIX = cairo_toy_font_face_
BOOT:
cairo_perl_set_isa ("Cairo::ToyFontFace", "Cairo::FontFace");
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 8, 0)
# cairo_font_face_t * cairo_toy_font_face_create (const char *family, cairo_font_slant_t slant, cairo_font_weight_t weight)
cairo_font_face_t_noinc *
cairo_toy_font_face_create (class, const char_utf8 *family, cairo_font_slant_t slant, cairo_font_weight_t weight)
C_ARGS:
family, slant, weight
POSTCALL:
#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_perl_package_table_insert (RETVAL, "Cairo::ToyFontFace");
#endif
const char_utf8 * cairo_toy_font_face_get_family (cairo_font_face_t *font_face);
cairo_font_slant_t cairo_toy_font_face_get_slant (cairo_font_face_t *font_face);
cairo_font_weight_t cairo_toy_font_face_get_weight (cairo_font_face_t *font_face);
#endif
# --------------------------------------------------------------------------- #
MODULE = Cairo::Font PACKAGE = Cairo::ScaledFont PREFIX = cairo_scaled_font_
##cairo_scaled_font_t* cairo_scaled_font_create (cairo_font_face_t *font_face, const cairo_matrix_t *font_matrix, const cairo_matrix_t *ctm, const cairo_font_options_t *options);
cairo_scaled_font_t_noinc * cairo_scaled_font_create (class, cairo_font_face_t *font_face, const cairo_matrix_t *font_matrix, const cairo_matrix_t *ctm, const cairo_font_options_t *options)
C_ARGS:
font_face, font_matrix, ctm, options
POSTCALL:
#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_perl_package_table_insert (RETVAL, "Cairo::ScaledFont");
#endif
cairo_status_t cairo_scaled_font_status (cairo_scaled_font_t *scaled_font);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_font_type_t cairo_scaled_font_get_type (cairo_scaled_font_t *scaled_font);
#endif
##cairo_status_t cairo_scaled_font_extents (cairo_scaled_font_t *scaled_font, cairo_font_extents_t *extents);
cairo_font_extents_t * cairo_scaled_font_extents (cairo_scaled_font_t *scaled_font)
PREINIT:
cairo_font_extents_t extents;
CODE:
cairo_scaled_font_extents (scaled_font, &extents);
RETVAL = &extents;
OUTPUT:
RETVAL
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
##void cairo_scaled_font_text_extents (cairo_scaled_font_t *scaled_font, const char *utf8, cairo_text_extents_t *extents);
cairo_text_extents_t * cairo_scaled_font_text_extents (cairo_scaled_font_t *scaled_font, const char_utf8 *utf8)
PREINIT:
cairo_text_extents_t extents;
CODE:
cairo_scaled_font_text_extents (scaled_font, utf8, &extents);
RETVAL = &extents;
OUTPUT:
RETVAL
#endif
##void cairo_scaled_font_glyph_extents (cairo_scaled_font_t *scaled_font, cairo_glyph_t *glyphs, int num_glyphs, cairo_text_extents_t *extents);
cairo_text_extents_t * cairo_scaled_font_glyph_extents (cairo_scaled_font_t *scaled_font, ...)
PREINIT:
cairo_glyph_t * glyphs = NULL;
int num_glyphs, i;
cairo_text_extents_t extents;
CODE:
num_glyphs = items - 1;
Newz (0, glyphs, num_glyphs, cairo_glyph_t);
for (i = 1; i < items; i++)
glyphs[i - 1] = *SvCairoGlyph (ST (i));
cairo_scaled_font_glyph_extents (scaled_font, glyphs, num_glyphs, &extents);
RETVAL = &extents;
Safefree (glyphs);
OUTPUT:
RETVAL
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 8, 0)
##cairo_status_t cairo_scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, double x, double y, const char *utf8, int utf8_len, cairo_glyph_t **glyphs, int *num_glyphs, cairo_text_cluster_t **clusters, int *num_clusters, cairo_text_cluster_flags_t *cluster_flags);
void
cairo_scaled_font_text_to_glyphs (cairo_scaled_font_t *scaled_font, double x, double y, SV *utf8_sv)
PREINIT:
const char *utf8;
STRLEN utf8_len;
cairo_glyph_t *glyphs = NULL;
int num_glyphs;
cairo_text_cluster_t *clusters = NULL;
int num_clusters;
cairo_text_cluster_flags_t cluster_flags;
cairo_status_t status;
PPCODE:
sv_utf8_upgrade (utf8_sv);
utf8 = SvPV (utf8_sv, utf8_len);
status = cairo_scaled_font_text_to_glyphs (
scaled_font,
x, y,
utf8, utf8_len,
&glyphs, &num_glyphs,
&clusters, &num_clusters, &cluster_flags);
PUSHs (sv_2mortal (newSVCairoStatus (status)));
if (CAIRO_STATUS_SUCCESS == status) {
AV *glyphs_av, *clusters_av;
int i;
glyphs_av = newAV ();
for (i = 0; i < num_glyphs; i++)
av_push (glyphs_av, newSVCairoGlyph (&glyphs[i]));
cairo_glyph_free (glyphs);
clusters_av = newAV ();
for (i = 0; i < num_clusters; i++)
av_push (clusters_av, newSVCairoTextCluster (&clusters[i]));
cairo_text_cluster_free (clusters);
EXTEND (SP, 4);
PUSHs (sv_2mortal (newRV_noinc ((SV *) glyphs_av)));
PUSHs (sv_2mortal (newRV_noinc ((SV *) clusters_av)));
PUSHs (sv_2mortal (newSVCairoTextClusterFlags (cluster_flags)));
}
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_font_face_t * cairo_scaled_font_get_font_face (cairo_scaled_font_t *scaled_font);
##void cairo_scaled_font_get_font_matrix (cairo_scaled_font_t *scaled_font, cairo_matrix_t *font_matrix);
cairo_matrix_t * cairo_scaled_font_get_font_matrix (cairo_scaled_font_t *scaled_font)
PREINIT:
cairo_matrix_t font_matrix;
CODE:
cairo_scaled_font_get_font_matrix (scaled_font, &font_matrix);
RETVAL = cairo_perl_copy_matrix (&font_matrix);
OUTPUT:
RETVAL
##void cairo_scaled_font_get_ctm (cairo_scaled_font_t *scaled_font, cairo_matrix_t *ctm);
cairo_matrix_t * cairo_scaled_font_get_ctm (cairo_scaled_font_t *scaled_font)
PREINIT:
cairo_matrix_t ctm;
CODE:
cairo_scaled_font_get_ctm (scaled_font, &ctm);
RETVAL = cairo_perl_copy_matrix (&ctm);
OUTPUT:
RETVAL
##void cairo_scaled_font_get_font_options (cairo_scaled_font_t *scaled_font, cairo_font_options_t *options);
cairo_font_options_t * cairo_scaled_font_get_font_options (cairo_scaled_font_t *scaled_font)
CODE:
RETVAL = cairo_font_options_create ();
cairo_scaled_font_get_font_options (scaled_font, RETVAL);
OUTPUT:
RETVAL
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 8, 0)
##void cairo_scaled_font_get_scale_matrix (cairo_scaled_font_t *scaled_font, cairo_matrix_t *scale_matrix);
cairo_matrix_t *
cairo_scaled_font_get_scale_matrix (cairo_scaled_font_t *scaled_font)
PREINIT:
cairo_matrix_t matrix;
CODE:
cairo_scaled_font_get_scale_matrix (scaled_font, &matrix);
RETVAL = cairo_perl_copy_matrix (&matrix);
OUTPUT:
RETVAL
#endif
void DESTROY (cairo_scaled_font_t * font)
CODE:
cairo_scaled_font_destroy (font);
# --------------------------------------------------------------------------- #
MODULE = Cairo::Font PACKAGE = Cairo::FontOptions PREFIX = cairo_font_options_
##cairo_font_options_t * cairo_font_options_create (void);
cairo_font_options_t * cairo_font_options_create (class)
C_ARGS:
/* void */
# FIXME: Necessary?
##cairo_font_options_t * cairo_font_options_copy (const cairo_font_options_t *original);
cairo_status_t cairo_font_options_status (cairo_font_options_t *options);
void cairo_font_options_merge (cairo_font_options_t *options, const cairo_font_options_t *other);
cairo_bool_t cairo_font_options_equal (const cairo_font_options_t *options, const cairo_font_options_t *other);
unsigned long cairo_font_options_hash (const cairo_font_options_t *options);
void cairo_font_options_set_antialias (cairo_font_options_t *options, cairo_antialias_t antialias);
cairo_antialias_t cairo_font_options_get_antialias (const cairo_font_options_t *options);
void cairo_font_options_set_subpixel_order (cairo_font_options_t *options, cairo_subpixel_order_t subpixel_order);
cairo_subpixel_order_t cairo_font_options_get_subpixel_order (const cairo_font_options_t *options);
void cairo_font_options_set_hint_style (cairo_font_options_t *options, cairo_hint_style_t hint_style);
cairo_hint_style_t cairo_font_options_get_hint_style (const cairo_font_options_t *options);
void cairo_font_options_set_hint_metrics (cairo_font_options_t *options, cairo_hint_metrics_t hint_metrics);
cairo_hint_metrics_t cairo_font_options_get_hint_metrics (const cairo_font_options_t *options);
void DESTROY (cairo_font_options_t *options)
CODE:
cairo_font_options_destroy (options);
Cairo-1.109/MANIFEST 000644 001750 000024 00000002153 14001743452 014144 0 ustar 00brian staff 000000 000000 cairo-perl-private.h
cairo-perl.h
cairo-perl.typemap
Cairo.xs
CairoFont.xs
CairoFt.xs
CairoMatrix.xs
CairoPath.xs
CairoPattern.xs
CairoRegion.xs
CairoSurface.xs
ChangeLog.pre-git
doctypes
examples/freetype-font.pl
examples/glyph-text.pl
examples/mime-unique-id.pl
examples/pdf-tagged-text.pl
examples/png-streams.pl
examples/png/bevels.pl
examples/png/caps_joins.pl
examples/png/hering.pl
examples/png/outline.pl
examples/png/README
examples/png/snapping.pl
examples/png/spiral.pl
examples/png/spline-pipeline.pl
examples/png/splines_tolerance.pl
examples/png/star_and_ring.pl
examples/png/stars.pl
examples/png/text-rotate.pl
examples/png/text.pl
examples/simple.pl
examples/subclassing.pl
examples/twisted-text.pl
inc/MakeHelper.pm
lib/Cairo.pm
LICENSE
Makefile.PL
MANIFEST
MANIFEST.SKIP
NEWS
perl-cairo.doap
ppport.h
README
t/00-loading.t
t/Cairo.t
t/CairoFont.t
t/CairoFt.t
t/CairoMatrix.t
t/CairoPath.t
t/CairoPattern.t
t/CairoRegion.t
t/CairoSurface.t
TODO
META.yml Module YAML meta-data (added by MakeMaker)
META.json Module JSON meta-data (added by MakeMaker)
Cairo-1.109/CairoSurface.xs 000644 001750 000024 00000064314 13757124331 015752 0 ustar 00brian staff 000000 000000 /*
* Copyright (c) 2004-2006, 2012-2013 by the cairo perl team (see the file
* README)
*
* Licensed under the LGPL, see LICENSE file for more information.
*
* $Id$
*/
#include
#include
#define NEED_sv_2pv_flags
#include "ppport.h"
#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
static HV *pointer_to_package = NULL;
/* A hex character represents four bits in the address of a pointer, so we'll
* need BITS_PER_POINTER/4 characters. That's sizeof (void*) * 2. Add 2 for
* the "0x" part. Add 1 for the trailing \0.
*/
#define MAX_KEY_LENGTH ((sizeof(void*) * 2) + 2 + 1)
/* This stuff is also used in CairoPattern.xs, hence no static on the
* functions.
*/
void
cairo_perl_package_table_insert (void *pointer, const char *package)
{
char key[MAX_KEY_LENGTH];
if (!pointer_to_package) {
pointer_to_package = newHV ();
}
sprintf (key, "%p", pointer);
hv_store (pointer_to_package, key, strlen (key), newSVpv (package, 0), 0);
}
const char *
cairo_perl_package_table_lookup (void *pointer)
{
char key[MAX_KEY_LENGTH];
SV **sv;
if (!pointer_to_package) {
return NULL;
}
sprintf (key, "%p", pointer);
sv = hv_fetch (pointer_to_package, key, strlen (key), 0);
if (sv && SvOK (*sv)) {
return SvPV_nolen (*sv);
}
return NULL;
}
#endif /* !1.2.0 */
static const char *
get_package (cairo_surface_t *surface)
{
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_surface_type_t type;
const char *package;
type = cairo_surface_get_type (surface);
switch (type) {
case CAIRO_SURFACE_TYPE_IMAGE:
package = "Cairo::ImageSurface";
break;
case CAIRO_SURFACE_TYPE_PDF:
package = "Cairo::PdfSurface";
break;
case CAIRO_SURFACE_TYPE_PS:
package = "Cairo::PsSurface";
break;
case CAIRO_SURFACE_TYPE_SVG:
package = "Cairo::SvgSurface";
break;
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)
case CAIRO_SURFACE_TYPE_RECORDING:
package = "Cairo::RecordingSurface";
break;
#endif
case CAIRO_SURFACE_TYPE_XLIB:
case CAIRO_SURFACE_TYPE_XCB:
case CAIRO_SURFACE_TYPE_GLITZ:
case CAIRO_SURFACE_TYPE_QUARTZ:
case CAIRO_SURFACE_TYPE_WIN32:
case CAIRO_SURFACE_TYPE_BEOS:
case CAIRO_SURFACE_TYPE_DIRECTFB:
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
case CAIRO_SURFACE_TYPE_OS2:
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0)
case CAIRO_SURFACE_TYPE_WIN32_PRINTING:
case CAIRO_SURFACE_TYPE_QUARTZ_IMAGE:
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)
case CAIRO_SURFACE_TYPE_SCRIPT:
case CAIRO_SURFACE_TYPE_QT:
case CAIRO_SURFACE_TYPE_VG:
case CAIRO_SURFACE_TYPE_GL:
case CAIRO_SURFACE_TYPE_DRM:
case CAIRO_SURFACE_TYPE_TEE:
case CAIRO_SURFACE_TYPE_XML:
case CAIRO_SURFACE_TYPE_SKIA:
case CAIRO_SURFACE_TYPE_SUBSURFACE:
#endif
package = "Cairo::Surface";
break;
default:
warn ("unknown surface type %d encountered", type);
package = "Cairo::Surface";
break;
}
return package;
#else
const char *package = cairo_perl_package_table_lookup (surface);
return package ? package : "Cairo::Surface";
#endif
}
SV *
cairo_surface_to_sv (cairo_surface_t *surface)
{
SV *sv = newSV (0);
sv_setref_pv(sv, get_package (surface), surface);
return sv;
}
/* -------------------------------------------------------------------------- */
typedef struct {
SV *func;
SV *data;
void *context;
} CairoPerlCallback;
#ifdef PERL_IMPLICIT_CONTEXT
# define dCAIRO_PERL_CALLBACK_MARSHAL_SP \
SV ** sp;
# define CAIRO_PERL_CALLBACK_MARSHAL_INIT(callback) \
PERL_SET_CONTEXT (callback->context); \
SPAGAIN;
#else
# define dCAIRO_PERL_CALLBACK_MARSHAL_SP \
dSP;
# define CAIRO_PERL_CALLBACK_MARSHAL_INIT(callback) \
/* nothing to do */
#endif
static CairoPerlCallback *
cairo_perl_callback_new (SV *func, SV *data)
{
CairoPerlCallback *callback;
Newz (0, callback, 1, CairoPerlCallback);
callback->func = newSVsv (func);
if (data)
callback->data = newSVsv (data);
#ifdef PERL_IMPLICIT_CONTEXT
callback->context = aTHX;
#endif
return callback;
}
static void
cairo_perl_callback_free (CairoPerlCallback *callback)
{
SvREFCNT_dec (callback->func);
if (callback->data)
SvREFCNT_dec (callback->data);
Safefree (callback);
}
/* -------------------------------------------------------------------------- */
/* Caller owns returned SV */
static SV *
strip_off_location (SV *error)
{
SV *saved_defsv, *result;
saved_defsv = newSVsv (DEFSV);
ENTER;
SAVETMPS;
sv_setsv (DEFSV, error);
eval_pv ("s/^([-_\\w]+) .+$/$1/s", FALSE);
result = newSVsv (DEFSV);
FREETMPS;
LEAVE;
sv_setsv (DEFSV, saved_defsv);
SvREFCNT_dec (saved_defsv);
return result;
}
static cairo_status_t
write_func_marshaller (void *closure,
const unsigned char *data,
unsigned int length)
{
CairoPerlCallback *callback;
cairo_status_t status = CAIRO_STATUS_SUCCESS;
dCAIRO_PERL_CALLBACK_MARSHAL_SP;
callback = (CairoPerlCallback *) closure;
CAIRO_PERL_CALLBACK_MARSHAL_INIT (callback);
ENTER;
SAVETMPS;
PUSHMARK (SP);
EXTEND (SP, 2);
PUSHs (callback->data ? callback->data : &PL_sv_undef);
PUSHs (sv_2mortal (newSVpv ((const char *) data, length)));
PUTBACK;
call_sv (callback->func, G_DISCARD | G_EVAL);
SPAGAIN;
if (SvTRUE (ERRSV)) {
SV *sv = strip_off_location (ERRSV);
status = SvCairoStatus (sv);
SvREFCNT_dec (sv);
}
PUTBACK;
FREETMPS;
LEAVE;
return status;
}
/* -------------------------------------------------------------------------- */
static cairo_status_t
read_func_marshaller (void *closure,
unsigned char *data,
unsigned int length)
{
CairoPerlCallback *callback;
cairo_status_t status = CAIRO_STATUS_SUCCESS;
dCAIRO_PERL_CALLBACK_MARSHAL_SP;
callback = (CairoPerlCallback *) closure;
CAIRO_PERL_CALLBACK_MARSHAL_INIT (callback);
ENTER;
SAVETMPS;
PUSHMARK (SP);
EXTEND (SP, 2);
PUSHs (callback->data ? callback->data : &PL_sv_undef);
PUSHs (sv_2mortal (newSVuv (length)));
PUTBACK;
call_sv (callback->func, G_SCALAR | G_EVAL);
SPAGAIN;
if (SvTRUE (ERRSV)) {
SV *sv = strip_off_location (ERRSV);
status = SvCairoStatus (sv);
SvREFCNT_dec (sv);
} else {
SV *retval = POPs;
STRLEN len = 0;
const char *sv_data = SvPV (retval, len);
/* should we assert that len == length? */
memcpy (data, sv_data, len);
}
PUTBACK;
FREETMPS;
LEAVE;
return status;
}
/* -------------------------------------------------------------------------- */
static void
data_destroy (void *data)
{
SvREFCNT_dec ((SV *) data);
}
/* -------------------------------------------------------------------------- */
MODULE = Cairo::Surface PACKAGE = Cairo::Surface PREFIX = cairo_surface_
void DESTROY (cairo_surface_t * surface);
CODE:
cairo_surface_destroy (surface);
cairo_surface_t_noinc *
cairo_surface_create_similar (...)
PREINIT:
int offset = 0;
cairo_surface_t * other = NULL;
cairo_content_t content = 0;
int width = 0;
int height = 0;
CODE:
if (items == 4) {
offset = 0;
} else if (items == 5) {
offset = 1;
} else {
croak ("Usage: Cairo::Surface->create_similar ($other, $content, $width, $height)\n"
" -or-: $other->create_similar ($content, $width, $height)");
}
other = SvCairoSurface (ST (0 + offset));
content = SvCairoContent (ST (1 + offset));
width = SvIV (ST (2 + offset));
height = SvIV (ST (3 + offset));
RETVAL = cairo_surface_create_similar (other, content, width, height);
#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
{
const char *package = cairo_perl_package_table_lookup (other);
cairo_perl_package_table_insert (RETVAL, package ? package : "Cairo::Surface");
}
#endif
OUTPUT:
RETVAL
void cairo_surface_finish (cairo_surface_t *surface);
cairo_status_t cairo_surface_status (cairo_surface_t *surface);
void cairo_surface_set_device_offset (cairo_surface_t *surface, double x_offset, double y_offset);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
void cairo_surface_get_device_offset (cairo_surface_t *surface, OUTLIST double x_offset, OUTLIST double y_offset);
void cairo_surface_set_fallback_resolution (cairo_surface_t *surface, double x_pixels_per_inch, double y_pixels_per_inch);
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 8, 0)
void cairo_surface_get_fallback_resolution (cairo_surface_t *surface, OUTLIST double x_pixels_per_inch, OUTLIST double y_pixels_per_inch);
#endif
##void cairo_surface_get_font_options (cairo_surface_t *surface, cairo_font_options_t *options);
cairo_font_options_t * cairo_surface_get_font_options (cairo_surface_t *surface)
CODE:
RETVAL = cairo_font_options_create ();
cairo_surface_get_font_options (surface, RETVAL);
OUTPUT:
RETVAL
void cairo_surface_flush (cairo_surface_t *surface);
void cairo_surface_mark_dirty (cairo_surface_t *surface);
void cairo_surface_mark_dirty_rectangle (cairo_surface_t *surface, int x, int y, int width, int height);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_surface_type_t cairo_surface_get_type (cairo_surface_t *surface);
cairo_content_t cairo_surface_get_content (cairo_surface_t *surface);
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)
# cairo_status_t cairo_surface_set_mime_data (cairo_surface_t *surface, const char *mime_type, const unsigned char *data, unsigned long length, cairo_destroy_func_t destroy, void *closure);
cairo_status_t
cairo_surface_set_mime_data (cairo_surface_t *surface, const char *mime_type, SV *data);
PREINIT:
const unsigned char *mime_data;
unsigned long length;
CODE:
SvREFCNT_inc (data);
mime_data = (const unsigned char *) SvPV(data, length);
RETVAL = cairo_surface_set_mime_data (surface, mime_type, mime_data, length, data_destroy, data);
OUTPUT:
RETVAL
# void cairo_surface_get_mime_data (cairo_surface_t *surface, const char *mime_type, const unsigned char **data, unsigned long *length);
SV *
cairo_surface_get_mime_data (cairo_surface_t *surface, const char *mime_type);
PREINIT:
const unsigned char *data;
unsigned long length;
CODE:
cairo_surface_get_mime_data (surface, mime_type, &data, &length);
RETVAL = newSVpvn ((const char *) data, length);
OUTPUT:
RETVAL
BOOT:
HV *stashsurface = gv_stashpv("Cairo::Surface", 0);
newCONSTSUB (stashsurface, "MIME_TYPE_JP2", newSVpv (CAIRO_MIME_TYPE_JP2, 0));
newCONSTSUB (stashsurface, "MIME_TYPE_JPEG", newSVpv (CAIRO_MIME_TYPE_JPEG, 0));
newCONSTSUB (stashsurface, "MIME_TYPE_PNG", newSVpv (CAIRO_MIME_TYPE_PNG, 0));
newCONSTSUB (stashsurface, "MIME_TYPE_URI", newSVpv (CAIRO_MIME_TYPE_URI, 0));
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
cairo_bool_t cairo_surface_supports_mime_type (cairo_surface_t *surface, const char *mime_type);
BOOT:
newCONSTSUB (stashsurface, "MIME_TYPE_UNIQUE_ID", newSVpv (CAIRO_MIME_TYPE_UNIQUE_ID, 0));
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 14, 0)
BOOT:
newCONSTSUB (stashsurface, "MIME_TYPE_JBIG2", newSVpv (CAIRO_MIME_TYPE_JBIG2, 0));
newCONSTSUB (stashsurface, "MIME_TYPE_JBIG2_GLOBAL", newSVpv (CAIRO_MIME_TYPE_JBIG2_GLOBAL, 0));
newCONSTSUB (stashsurface, "MIME_TYPE_JBIG2_GLOBAL_ID", newSVpv (CAIRO_MIME_TYPE_JBIG2_GLOBAL_ID, 0));
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 16, 0)
BOOT:
newCONSTSUB (stashsurface, "MIME_TYPE_CCITT_FAX", newSVpv (CAIRO_MIME_TYPE_CCITT_FAX, 0));
newCONSTSUB (stashsurface, "MIME_TYPE_CCITT_FAX_PARAMS", newSVpv (CAIRO_MIME_TYPE_CCITT_FAX_PARAMS, 0));
newCONSTSUB (stashsurface, "MIME_TYPE_EPS", newSVpv (CAIRO_MIME_TYPE_EPS, 0));
newCONSTSUB (stashsurface, "MIME_TYPE_EPS_PARAMS", newSVpv (CAIRO_MIME_TYPE_EPS_PARAMS, 0));
#endif
#ifdef CAIRO_HAS_PNG_FUNCTIONS
cairo_status_t cairo_surface_write_to_png (cairo_surface_t *surface, const char *filename);
##cairo_status_t cairo_surface_write_to_png_stream (cairo_surface_t *surface, cairo_write_func_t write_func, void *closure);
cairo_status_t
cairo_surface_write_to_png_stream (cairo_surface_t *surface, SV *func, SV *data=NULL)
PREINIT:
CairoPerlCallback *callback;
CODE:
callback = cairo_perl_callback_new (func, data);
RETVAL = cairo_surface_write_to_png_stream (surface,
write_func_marshaller,
callback);
cairo_perl_callback_free (callback);
OUTPUT:
RETVAL
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE (1, 6, 0)
void cairo_surface_copy_page (cairo_surface_t *surface);
void cairo_surface_show_page (cairo_surface_t *surface);
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE (1, 8, 0)
cairo_bool_t cairo_surface_has_show_text_glyphs (cairo_surface_t *surface);
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE (1, 10, 0)
# cairo_surface_t * cairo_surface_create_for_rectangle (cairo_surface_t *target, double x, double y, double width, double height);
cairo_surface_t_noinc *
cairo_surface_create_for_rectangle (class, cairo_surface_t *target, double x, double y, double width, double height)
C_ARGS:
target, x, y, width, height
#endif
# --------------------------------------------------------------------------- #
MODULE = Cairo::Surface PACKAGE = Cairo::ImageSurface PREFIX = cairo_image_surface_
BOOT:
cairo_perl_set_isa ("Cairo::ImageSurface", "Cairo::Surface");
##cairo_surface_t * cairo_image_surface_create (cairo_format_t format, int width, int height);
cairo_surface_t_noinc * cairo_image_surface_create (class, cairo_format_t format, int width, int height)
C_ARGS:
format, width, height
POSTCALL:
#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_perl_package_table_insert (RETVAL, "Cairo::ImageSurface");
#endif
##cairo_surface_t * cairo_image_surface_create_for_data (unsigned char *data, cairo_format_t format, int width, int height, int stride);
cairo_surface_t_noinc * cairo_image_surface_create_for_data (class, unsigned char *data, cairo_format_t format, int width, int height, int stride)
C_ARGS:
data, format, width, height, stride
POSTCALL:
#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_perl_package_table_insert (RETVAL, "Cairo::ImageSurface");
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
# unsigned char * cairo_image_surface_get_data (cairo_surface_t *surface);
SV *
cairo_image_surface_get_data (cairo_surface_t *surface)
PREINIT:
unsigned char *data;
int height, stride;
CODE:
data = cairo_image_surface_get_data (surface);
height = cairo_image_surface_get_height (surface);
stride = cairo_image_surface_get_stride (surface);
RETVAL = data ? newSVpv ((char *) data, height * stride) : &PL_sv_undef;
OUTPUT:
RETVAL
cairo_format_t cairo_image_surface_get_format (cairo_surface_t *surface);
#endif
int cairo_image_surface_get_width (cairo_surface_t *surface);
int cairo_image_surface_get_height (cairo_surface_t *surface);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
int cairo_image_surface_get_stride (cairo_surface_t *surface);
#endif
#ifdef CAIRO_HAS_PNG_FUNCTIONS
##cairo_surface_t * cairo_image_surface_create_from_png (const char *filename);
cairo_surface_t_noinc * cairo_image_surface_create_from_png (class, const char *filename)
C_ARGS:
filename
POSTCALL:
#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_perl_package_table_insert (RETVAL, "Cairo::ImageSurface");
#endif
##cairo_surface_t * cairo_image_surface_create_from_png_stream (cairo_read_func_t read_func, void *closure);
cairo_surface_t_noinc *
cairo_image_surface_create_from_png_stream (class, SV *func, SV *data=NULL)
PREINIT:
CairoPerlCallback *callback;
CODE:
callback = cairo_perl_callback_new (func, data);
RETVAL = cairo_image_surface_create_from_png_stream (
read_func_marshaller, callback);
cairo_perl_callback_free (callback);
#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_perl_package_table_insert (RETVAL, "Cairo::ImageSurface");
#endif
OUTPUT:
RETVAL
#endif
# --------------------------------------------------------------------------- #
#ifdef CAIRO_HAS_PDF_SURFACE
MODULE = Cairo::Surface PACKAGE = Cairo::PdfSurface PREFIX = cairo_pdf_surface_
BOOT:
cairo_perl_set_isa ("Cairo::PdfSurface", "Cairo::Surface");
##cairo_surface_t * cairo_pdf_surface_create (const char *filename, double width_in_points, double height_in_points);
cairo_surface_t_noinc * cairo_pdf_surface_create (class, const char *filename, double width_in_points, double height_in_points)
C_ARGS:
filename, width_in_points, height_in_points
POSTCALL:
#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_perl_package_table_insert (RETVAL, "Cairo::PdfSurface");
#endif
##cairo_surface_t * cairo_pdf_surface_create_for_stream (cairo_write_func_t write_func, void *closure, double width_in_points, double height_in_points);
cairo_surface_t_noinc *
cairo_pdf_surface_create_for_stream (class, SV *func, SV *data, double width_in_points, double height_in_points)
PREINIT:
CairoPerlCallback *callback;
CODE:
callback = cairo_perl_callback_new (func, data);
RETVAL = cairo_pdf_surface_create_for_stream (write_func_marshaller,
callback,
width_in_points,
height_in_points);
cairo_surface_set_user_data (
RETVAL, (const cairo_user_data_key_t *) &callback, callback,
(cairo_destroy_func_t) cairo_perl_callback_free);
#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_perl_package_table_insert (RETVAL, "Cairo::PdfSurface");
#endif
OUTPUT:
RETVAL
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
void cairo_pdf_surface_set_size (cairo_surface_t *surface, double width_in_points, double height_in_points);
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)
void cairo_pdf_surface_restrict_to_version (cairo_surface_t *surface, cairo_pdf_version_t version);
# void cairo_pdf_get_versions (cairo_pdf_version_t const **versions, int *num_versions);
void
cairo_pdf_surface_get_versions (class=NULL)
PREINIT:
cairo_pdf_version_t const *versions = NULL;
int num_versions = 0, i;
PPCODE:
PERL_UNUSED_VAR (ax);
cairo_pdf_get_versions (&versions, &num_versions);
EXTEND (sp, num_versions);
for (i = 0; i < num_versions; i++)
PUSHs (sv_2mortal (newSVCairoPdfVersion (versions[i])));
# const char * cairo_pdf_version_to_string (cairo_pdf_version_t version);
const char *
cairo_pdf_surface_version_to_string (...)
CODE:
if (items == 1) {
RETVAL = cairo_pdf_version_to_string (SvCairoPdfVersion (ST (0)));
} else if (items == 2) {
RETVAL = cairo_pdf_version_to_string (SvCairoPdfVersion (ST (1)));
} else {
RETVAL = NULL;
croak ("Usage: Cairo::PdfSurface::version_to_string (version) or Cairo::PdfSurface->version_to_string (version)");
}
OUTPUT:
RETVAL
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 16, 0)
int cairo_pdf_surface_add_outline (cairo_surface_t *surface, int parent_id, const char *utf8, const char *link_attribs, cairo_pdf_outline_flags_t flags);
BOOT:
HV *stashpdfsurface = gv_stashpv("Cairo::PdfSurface", 0);
newCONSTSUB(stashpdfsurface, "OUTLINE_ROOT", newSViv(CAIRO_PDF_OUTLINE_ROOT));
void cairo_pdf_surface_set_metadata (cairo_surface_t *surface, cairo_pdf_metadata_t metadata, const char_utf8 * utf8);
void cairo_pdf_surface_set_page_label (cairo_surface_t *surface, const char *utf8);
void cairo_pdf_surface_set_thumbnail_size (cairo_surface_t *surface, int width, int height);
#endif
#endif
# --------------------------------------------------------------------------- #
#ifdef CAIRO_HAS_PS_SURFACE
MODULE = Cairo::Surface PACKAGE = Cairo::PsSurface PREFIX = cairo_ps_surface_
BOOT:
cairo_perl_set_isa ("Cairo::PsSurface", "Cairo::Surface");
##cairo_surface_t * cairo_ps_surface_create (const char *filename, double width_in_points, double height_in_points);
cairo_surface_t_noinc * cairo_ps_surface_create (class, const char *filename, double width_in_points, double height_in_points)
C_ARGS:
filename, width_in_points, height_in_points
POSTCALL:
#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_perl_package_table_insert (RETVAL, "Cairo::PsSurface");
#endif
##cairo_surface_t * cairo_ps_surface_create_for_stream (cairo_write_func_t write_func, void *closure, double width_in_points, double height_in_points);
cairo_surface_t_noinc *
cairo_ps_surface_create_for_stream (class, SV *func, SV *data, double width_in_points, double height_in_points)
PREINIT:
CairoPerlCallback *callback;
CODE:
callback = cairo_perl_callback_new (func, data);
RETVAL = cairo_ps_surface_create_for_stream (write_func_marshaller,
callback,
width_in_points,
height_in_points);
cairo_surface_set_user_data (
RETVAL, (const cairo_user_data_key_t *) &callback, callback,
(cairo_destroy_func_t) cairo_perl_callback_free);
#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_perl_package_table_insert (RETVAL, "Cairo::PsSurface");
#endif
OUTPUT:
RETVAL
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
void cairo_ps_surface_set_size (cairo_surface_t *surface, double width_in_points, double height_in_points);
void cairo_ps_surface_dsc_comment (cairo_surface_t *surface, const char *comment);
void cairo_ps_surface_dsc_begin_setup (cairo_surface_t *surface);
void cairo_ps_surface_dsc_begin_page_setup (cairo_surface_t *surface);
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0)
void cairo_ps_surface_restrict_to_level (cairo_surface_t *surface, cairo_ps_level_t level);
# void cairo_ps_get_levels (cairo_ps_level_t const **levels, int *num_levels);
void
cairo_ps_surface_get_levels (class=NULL)
PREINIT:
cairo_ps_level_t const *levels = NULL;
int num_levels = 0, i;
PPCODE:
PERL_UNUSED_VAR (ax);
cairo_ps_get_levels (&levels, &num_levels);
EXTEND (sp, num_levels);
for (i = 0; i < num_levels; i++)
PUSHs (sv_2mortal (newSVCairoPsLevel (levels[i])));
# const char * cairo_ps_level_to_string (cairo_ps_level_t level);
const char *
cairo_ps_surface_level_to_string (...)
CODE:
if (items == 1) {
RETVAL = cairo_ps_level_to_string (SvCairoPsLevel (ST (0)));
} else if (items == 2) {
RETVAL = cairo_ps_level_to_string (SvCairoPsLevel (ST (1)));
} else {
RETVAL = NULL;
croak ("Usage: Cairo::PsSurface::level_to_string (level) or Cairo::PsSurface->level_to_string (level)");
}
OUTPUT:
RETVAL
void cairo_ps_surface_set_eps (cairo_surface_t *surface, cairo_bool_t eps);
cairo_bool_t cairo_ps_surface_get_eps (cairo_surface_t *surface);
#endif
#endif
# --------------------------------------------------------------------------- #
# The SVG surface doesn't need the special package treatment because it didn't
# exist in cairo 1.0.
#ifdef CAIRO_HAS_SVG_SURFACE
MODULE = Cairo::Surface PACKAGE = Cairo::SvgSurface PREFIX = cairo_svg_surface_
BOOT:
cairo_perl_set_isa ("Cairo::SvgSurface", "Cairo::Surface");
# cairo_surface_t * cairo_svg_surface_create (const char *filename, double width_in_points, double height_in_points);
cairo_surface_t_noinc *
cairo_svg_surface_create (class, const char *filename, double width_in_points, double height_in_points)
C_ARGS:
filename, width_in_points, height_in_points
# cairo_surface_t * cairo_svg_surface_create_for_stream (cairo_write_func_t write_func, void *closure, double width_in_points, double height_in_points);
cairo_surface_t_noinc *
cairo_svg_surface_create_for_stream (class, SV *func, SV *data, double width_in_points, double height_in_points)
PREINIT:
CairoPerlCallback *callback;
CODE:
callback = cairo_perl_callback_new (func, data);
RETVAL = cairo_svg_surface_create_for_stream (write_func_marshaller,
callback,
width_in_points,
height_in_points);
cairo_surface_set_user_data (
RETVAL, (const cairo_user_data_key_t *) &callback, callback,
(cairo_destroy_func_t) cairo_perl_callback_free);
OUTPUT:
RETVAL
void cairo_svg_surface_restrict_to_version (cairo_surface_t *surface, cairo_svg_version_t version);
# void cairo_svg_get_versions (cairo_svg_version_t const **versions, int *num_versions);
void
cairo_svg_surface_get_versions (class=NULL)
PREINIT:
cairo_svg_version_t const *versions = NULL;
int num_versions = 0, i;
PPCODE:
PERL_UNUSED_VAR (ax);
cairo_svg_get_versions (&versions, &num_versions);
EXTEND (sp, num_versions);
for (i = 0; i < num_versions; i++)
PUSHs (sv_2mortal (newSVCairoSvgVersion (versions[i])));
# const char * cairo_svg_version_to_string (cairo_svg_version_t version);
const char *
cairo_svg_surface_version_to_string (...)
CODE:
if (items == 1) {
RETVAL = cairo_svg_version_to_string (SvCairoSvgVersion (ST (0)));
} else if (items == 2) {
RETVAL = cairo_svg_version_to_string (SvCairoSvgVersion (ST (1)));
} else {
RETVAL = NULL;
croak ("Usage: Cairo::SvgSurface::version_to_string (version) or Cairo::SvgSurface->version_to_string (version)");
}
OUTPUT:
RETVAL
#endif
# --------------------------------------------------------------------------- #
# The recording surface doesn't need the special package treatment because it
# didn't exist in cairo 1.0.
#ifdef CAIRO_HAS_RECORDING_SURFACE
MODULE = Cairo::Surface PACKAGE = Cairo::RecordingSurface PREFIX = cairo_recording_surface_
BOOT:
cairo_perl_set_isa ("Cairo::RecordingSurface", "Cairo::Surface");
# cairo_surface_t * cairo_recording_surface_create (cairo_content_t, const cairo_rectangle_t *extents);
cairo_surface_t_noinc *
cairo_recording_surface_create (class, cairo_content_t content, cairo_rectangle_t_ornull *extents)
C_ARGS:
content, extents
void cairo_recording_surface_ink_extents (cairo_surface_t *surface, OUTLIST double x0, OUTLIST double y0, OUTLIST double width, OUTLIST double height);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 12, 0)
# cairo_bool_t cairo_recording_surface_get_extents (cairo_surface_t *surface, cairo_rectangle_t *extents);
cairo_rectangle_t *
cairo_recording_surface_get_extents (cairo_surface_t *surface)
PREINIT:
cairo_bool_t status;
cairo_rectangle_t rect;
CODE:
status = cairo_recording_surface_get_extents (surface, &rect);
RETVAL = status ? &rect : NULL;
OUTPUT:
RETVAL
#endif
#endif
# --------------------------------------------------------------------------- #
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0)
MODULE = Cairo::Surface PACKAGE = Cairo::Format PREFIX = cairo_format_
=for apidoc __function__
=cut
int cairo_format_stride_for_width (cairo_format_t format, int width);
#endif
Cairo-1.109/ppport.h 000644 001750 000024 00000456515 11664366475 014551 0 ustar 00brian staff 000000 000000 #if 0
<<'SKIP';
#endif
/*
----------------------------------------------------------------------
ppport.h -- Perl/Pollution/Portability Version 3.12
Automatically created by Devel::PPPort running under perl 5.008008.
Do NOT edit this file directly! -- Edit PPPort_pm.PL and the
includes in parts/inc/ instead.
Use 'perldoc ppport.h' to view the documentation below.
----------------------------------------------------------------------
SKIP
=pod
=head1 NAME
ppport.h - Perl/Pollution/Portability version 3.12
=head1 SYNOPSIS
perl ppport.h [options] [source files]
Searches current directory for files if no [source files] are given
--help show short help
--version show version
--patch=file write one patch file with changes
--copy=suffix write changed copies with suffix
--diff=program use diff program and options
--compat-version=version provide compatibility with Perl version
--cplusplus accept C++ comments
--quiet don't output anything except fatal errors
--nodiag don't show diagnostics
--nohints don't show hints
--nochanges don't suggest changes
--nofilter don't filter input files
--strip strip all script and doc functionality from
ppport.h
--list-provided list provided API
--list-unsupported list unsupported API
--api-info=name show Perl API portability information
=head1 COMPATIBILITY
This version of F is designed to support operation with Perl
installations back to 5.003, and has been tested up to 5.10.0.
=head1 OPTIONS
=head2 --help
Display a brief usage summary.
=head2 --version
Display the version of F.
=head2 --patch=I
If this option is given, a single patch file will be created if
any changes are suggested. This requires a working diff program
to be installed on your system.
=head2 --copy=I
If this option is given, a copy of each file will be saved with
the given suffix that contains the suggested changes. This does
not require any external programs. Note that this does not
automagially add a dot between the original filename and the
suffix. If you want the dot, you have to include it in the option
argument.
If neither C<--patch> or C<--copy> are given, the default is to
simply print the diffs for each file. This requires either
C or a C program to be installed.
=head2 --diff=I
Manually set the diff program and options to use. The default
is to use C, when installed, and output unified
context diffs.
=head2 --compat-version=I
Tell F to check for compatibility with the given
Perl version. The default is to check for compatibility with Perl
version 5.003. You can use this option to reduce the output
of F if you intend to be backward compatible only
down to a certain Perl version.
=head2 --cplusplus
Usually, F will detect C++ style comments and
replace them with C style comments for portability reasons.
Using this option instructs F to leave C++
comments untouched.
=head2 --quiet
Be quiet. Don't print anything except fatal errors.
=head2 --nodiag
Don't output any diagnostic messages. Only portability
alerts will be printed.
=head2 --nohints
Don't output any hints. Hints often contain useful portability
notes. Warnings will still be displayed.
=head2 --nochanges
Don't suggest any changes. Only give diagnostic output and hints
unless these are also deactivated.
=head2 --nofilter
Don't filter the list of input files. By default, files not looking
like source code (i.e. not *.xs, *.c, *.cc, *.cpp or *.h) are skipped.
=head2 --strip
Strip all script and documentation functionality from F.
This reduces the size of F dramatically and may be useful
if you want to include F in smaller modules without
increasing their distribution size too much.
The stripped F will have a C<--unstrip> option that allows
you to undo the stripping, but only if an appropriate C
module is installed.
=head2 --list-provided
Lists the API elements for which compatibility is provided by
F. Also lists if it must be explicitly requested,
if it has dependencies, and if there are hints or warnings for it.
=head2 --list-unsupported
Lists the API elements that are known not to be supported by
F and below which version of Perl they probably
won't be available or work.
=head2 --api-info=I
Show portability information for API elements matching I.
If I is surrounded by slashes, it is interpreted as a regular
expression.
=head1 DESCRIPTION
In order for a Perl extension (XS) module to be as portable as possible
across differing versions of Perl itself, certain steps need to be taken.
=over 4
=item *
Including this header is the first major one. This alone will give you
access to a large part of the Perl API that hasn't been available in
earlier Perl releases. Use
perl ppport.h --list-provided
to see which API elements are provided by ppport.h.
=item *
You should avoid using deprecated parts of the API. For example, using
global Perl variables without the C prefix is deprecated. Also,
some API functions used to have a C prefix. Using this form is
also deprecated. You can safely use the supported API, as F
will provide wrappers for older Perl versions.
=item *
If you use one of a few functions or variables that were not present in
earlier versions of Perl, and that can't be provided using a macro, you
have to explicitly request support for these functions by adding one or
more C<#define>s in your source code before the inclusion of F.
These functions or variables will be marked C in the list shown
by C<--list-provided>.
Depending on whether you module has a single or multiple files that
use such functions or variables, you want either C or global
variants.
For a C function or variable (used only in a single source
file), use:
#define NEED_function
#define NEED_variable
For a global function or variable (used in multiple source files),
use:
#define NEED_function_GLOBAL
#define NEED_variable_GLOBAL
Note that you mustn't have more than one global request for the
same function or variable in your project.
Function / Variable Static Request Global Request
-----------------------------------------------------------------------------------------
PL_signals NEED_PL_signals NEED_PL_signals_GLOBAL
eval_pv() NEED_eval_pv NEED_eval_pv_GLOBAL
grok_bin() NEED_grok_bin NEED_grok_bin_GLOBAL
grok_hex() NEED_grok_hex NEED_grok_hex_GLOBAL
grok_number() NEED_grok_number NEED_grok_number_GLOBAL
grok_numeric_radix() NEED_grok_numeric_radix NEED_grok_numeric_radix_GLOBAL
grok_oct() NEED_grok_oct NEED_grok_oct_GLOBAL
load_module() NEED_load_module NEED_load_module_GLOBAL
my_snprintf() NEED_my_snprintf NEED_my_snprintf_GLOBAL
my_strlcat() NEED_my_strlcat NEED_my_strlcat_GLOBAL
my_strlcpy() NEED_my_strlcpy NEED_my_strlcpy_GLOBAL
newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL
newRV_noinc() NEED_newRV_noinc NEED_newRV_noinc_GLOBAL
newSVpvn_share() NEED_newSVpvn_share NEED_newSVpvn_share_GLOBAL
sv_2pv_flags() NEED_sv_2pv_flags NEED_sv_2pv_flags_GLOBAL
sv_2pvbyte() NEED_sv_2pvbyte NEED_sv_2pvbyte_GLOBAL
sv_catpvf_mg() NEED_sv_catpvf_mg NEED_sv_catpvf_mg_GLOBAL
sv_catpvf_mg_nocontext() NEED_sv_catpvf_mg_nocontext NEED_sv_catpvf_mg_nocontext_GLOBAL
sv_pvn_force_flags() NEED_sv_pvn_force_flags NEED_sv_pvn_force_flags_GLOBAL
sv_setpvf_mg() NEED_sv_setpvf_mg NEED_sv_setpvf_mg_GLOBAL
sv_setpvf_mg_nocontext() NEED_sv_setpvf_mg_nocontext NEED_sv_setpvf_mg_nocontext_GLOBAL
vload_module() NEED_vload_module NEED_vload_module_GLOBAL
vnewSVpvf() NEED_vnewSVpvf NEED_vnewSVpvf_GLOBAL
warner() NEED_warner NEED_warner_GLOBAL
To avoid namespace conflicts, you can change the namespace of the
explicitly exported functions / variables using the C
macro. Just C<#define> the macro before including C:
#define DPPP_NAMESPACE MyOwnNamespace_
#include "ppport.h"
The default namespace is C.
=back
The good thing is that most of the above can be checked by running
F on your source code. See the next section for
details.
=head1 EXAMPLES
To verify whether F is needed for your module, whether you
should make any changes to your code, and whether any special defines
should be used, F can be run as a Perl script to check your
source code. Simply say:
perl ppport.h
The result will usually be a list of patches suggesting changes
that should at least be acceptable, if not necessarily the most
efficient solution, or a fix for all possible problems.
If you know that your XS module uses features only available in
newer Perl releases, if you're aware that it uses C++ comments,
and if you want all suggestions as a single patch file, you could
use something like this:
perl ppport.h --compat-version=5.6.0 --cplusplus --patch=test.diff
If you only want your code to be scanned without any suggestions
for changes, use:
perl ppport.h --nochanges
You can specify a different C program or options, using
the C<--diff> option:
perl ppport.h --diff='diff -C 10'
This would output context diffs with 10 lines of context.
If you want to create patched copies of your files instead, use:
perl ppport.h --copy=.new
To display portability information for the C function,
use:
perl ppport.h --api-info=newSVpvn
Since the argument to C<--api-info> can be a regular expression,
you can use
perl ppport.h --api-info=/_nomg$/
to display portability information for all C<_nomg> functions or
perl ppport.h --api-info=/./
to display information for all known API elements.
=head1 BUGS
If this version of F is causing failure during
the compilation of this module, please check if newer versions
of either this module or C are available on CPAN
before sending a bug report.
If F was generated using the latest version of
C and is causing failure of this module, please
file a bug report using the CPAN Request Tracker at L.
Please include the following information:
=over 4
=item 1.
The complete output from running "perl -V"
=item 2.
This file.
=item 3.
The name and version of the module you were trying to build.
=item 4.
A full log of the build that failed.
=item 5.
Any other information that you think could be relevant.
=back
For the latest version of this code, please get the C
module from CPAN.
=head1 COPYRIGHT
Version 3.x, Copyright (c) 2004-2007, Marcus Holland-Moritz.
Version 2.x, Copyright (C) 2001, Paul Marquess.
Version 1.x, Copyright (C) 1999, Kenneth Albanowski.
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
=head1 SEE ALSO
See L.
=cut
use strict;
# Disable broken TRIE-optimization
BEGIN { eval '${^RE_TRIE_MAXBUF} = -1' if $] >= 5.009004 && $] <= 5.009005 }
my $VERSION = 3.12;
my %opt = (
quiet => 0,
diag => 1,
hints => 1,
changes => 1,
cplusplus => 0,
filter => 1,
strip => 0,
version => 0,
);
my($ppport) = $0 =~ /([\w.]+)$/;
my $LF = '(?:\r\n|[\r\n])'; # line feed
my $HS = "[ \t]"; # horizontal whitespace
# Never use C comments in this file!
my $ccs = '/'.'*';
my $cce = '*'.'/';
my $rccs = quotemeta $ccs;
my $rcce = quotemeta $cce;
eval {
require Getopt::Long;
Getopt::Long::GetOptions(\%opt, qw(
help quiet diag! filter! hints! changes! cplusplus strip version
patch=s copy=s diff=s compat-version=s
list-provided list-unsupported api-info=s
)) or usage();
};
if ($@ and grep /^-/, @ARGV) {
usage() if "@ARGV" =~ /^--?h(?:elp)?$/;
die "Getopt::Long not found. Please don't use any options.\n";
}
if ($opt{version}) {
print "This is $0 $VERSION.\n";
exit 0;
}
usage() if $opt{help};
strip() if $opt{strip};
if (exists $opt{'compat-version'}) {
my($r,$v,$s) = eval { parse_version($opt{'compat-version'}) };
if ($@) {
die "Invalid version number format: '$opt{'compat-version'}'\n";
}
die "Only Perl 5 is supported\n" if $r != 5;
die "Invalid version number: $opt{'compat-version'}\n" if $v >= 1000 || $s >= 1000;
$opt{'compat-version'} = sprintf "%d.%03d%03d", $r, $v, $s;
}
else {
$opt{'compat-version'} = 5;
}
my %API = map { /^(\w+)\|([^|]*)\|([^|]*)\|(\w*)$/
? ( $1 => {
($2 ? ( base => $2 ) : ()),
($3 ? ( todo => $3 ) : ()),
(index($4, 'v') >= 0 ? ( varargs => 1 ) : ()),
(index($4, 'p') >= 0 ? ( provided => 1 ) : ()),
(index($4, 'n') >= 0 ? ( nothxarg => 1 ) : ()),
} )
: die "invalid spec: $_" } qw(
AvFILLp|5.004050||p
AvFILL|||
CLASS|||n
CX_CURPAD_SAVE|||
CX_CURPAD_SV|||
CopFILEAV|5.006000||p
CopFILEGV_set|5.006000||p
CopFILEGV|5.006000||p
CopFILESV|5.006000||p
CopFILE_set|5.006000||p
CopFILE|5.006000||p
CopSTASHPV_set|5.006000||p
CopSTASHPV|5.006000||p
CopSTASH_eq|5.006000||p
CopSTASH_set|5.006000||p
CopSTASH|5.006000||p
CopyD|5.009002||p
Copy|||
CvPADLIST|||
CvSTASH|||
CvWEAKOUTSIDE|||
DEFSV|5.004050||p
END_EXTERN_C|5.005000||p
ENTER|||
ERRSV|5.004050||p
EXTEND|||
EXTERN_C|5.005000||p
F0convert|||n
FREETMPS|||
GIMME_V||5.004000|n
GIMME|||n
GROK_NUMERIC_RADIX|5.007002||p
G_ARRAY|||
G_DISCARD|||
G_EVAL|||
G_NOARGS|||
G_SCALAR|||
G_VOID||5.004000|
GetVars|||
GvSV|||
Gv_AMupdate|||
HEf_SVKEY||5.004000|
HeHASH||5.004000|
HeKEY||5.004000|
HeKLEN||5.004000|
HePV||5.004000|
HeSVKEY_force||5.004000|
HeSVKEY_set||5.004000|
HeSVKEY||5.004000|
HeVAL||5.004000|
HvNAME|||
INT2PTR|5.006000||p
IN_LOCALE_COMPILETIME|5.007002||p
IN_LOCALE_RUNTIME|5.007002||p
IN_LOCALE|5.007002||p
IN_PERL_COMPILETIME|5.008001||p
IS_NUMBER_GREATER_THAN_UV_MAX|5.007002||p
IS_NUMBER_INFINITY|5.007002||p
IS_NUMBER_IN_UV|5.007002||p
IS_NUMBER_NAN|5.007003||p
IS_NUMBER_NEG|5.007002||p
IS_NUMBER_NOT_INT|5.007002||p
IVSIZE|5.006000||p
IVTYPE|5.006000||p
IVdf|5.006000||p
LEAVE|||
LVRET|||
MARK|||
MULTICALL||5.009005|
MY_CXT_CLONE|5.009002||p
MY_CXT_INIT|5.007003||p
MY_CXT|5.007003||p
MoveD|5.009002||p
Move|||
NOOP|5.005000||p
NUM2PTR|5.006000||p
NVTYPE|5.006000||p
NVef|5.006001||p
NVff|5.006001||p
NVgf|5.006001||p
Newxc|5.009003||p
Newxz|5.009003||p
Newx|5.009003||p
Nullav|||
Nullch|||
Nullcv|||
Nullhv|||
Nullsv|||
ORIGMARK|||
PAD_BASE_SV|||
PAD_CLONE_VARS|||
PAD_COMPNAME_FLAGS|||
PAD_COMPNAME_GEN_set|||
PAD_COMPNAME_GEN|||
PAD_COMPNAME_OURSTASH|||
PAD_COMPNAME_PV|||
PAD_COMPNAME_TYPE|||
PAD_RESTORE_LOCAL|||
PAD_SAVE_LOCAL|||
PAD_SAVE_SETNULLPAD|||
PAD_SETSV|||
PAD_SET_CUR_NOSAVE|||
PAD_SET_CUR|||
PAD_SVl|||
PAD_SV|||
PERL_ABS|5.008001||p
PERL_BCDVERSION|5.009005||p
PERL_GCC_BRACE_GROUPS_FORBIDDEN|5.008001||p
PERL_HASH|5.004000||p
PERL_INT_MAX|5.004000||p
PERL_INT_MIN|5.004000||p
PERL_LONG_MAX|5.004000||p
PERL_LONG_MIN|5.004000||p
PERL_MAGIC_arylen|5.007002||p
PERL_MAGIC_backref|5.007002||p
PERL_MAGIC_bm|5.007002||p
PERL_MAGIC_collxfrm|5.007002||p
PERL_MAGIC_dbfile|5.007002||p
PERL_MAGIC_dbline|5.007002||p
PERL_MAGIC_defelem|5.007002||p
PERL_MAGIC_envelem|5.007002||p
PERL_MAGIC_env|5.007002||p
PERL_MAGIC_ext|5.007002||p
PERL_MAGIC_fm|5.007002||p
PERL_MAGIC_glob|5.009005||p
PERL_MAGIC_isaelem|5.007002||p
PERL_MAGIC_isa|5.007002||p
PERL_MAGIC_mutex|5.009005||p
PERL_MAGIC_nkeys|5.007002||p
PERL_MAGIC_overload_elem|5.007002||p
PERL_MAGIC_overload_table|5.007002||p
PERL_MAGIC_overload|5.007002||p
PERL_MAGIC_pos|5.007002||p
PERL_MAGIC_qr|5.007002||p
PERL_MAGIC_regdata|5.007002||p
PERL_MAGIC_regdatum|5.007002||p
PERL_MAGIC_regex_global|5.007002||p
PERL_MAGIC_shared_scalar|5.007003||p
PERL_MAGIC_shared|5.007003||p
PERL_MAGIC_sigelem|5.007002||p
PERL_MAGIC_sig|5.007002||p
PERL_MAGIC_substr|5.007002||p
PERL_MAGIC_sv|5.007002||p
PERL_MAGIC_taint|5.007002||p
PERL_MAGIC_tiedelem|5.007002||p
PERL_MAGIC_tiedscalar|5.007002||p
PERL_MAGIC_tied|5.007002||p
PERL_MAGIC_utf8|5.008001||p
PERL_MAGIC_uvar_elem|5.007003||p
PERL_MAGIC_uvar|5.007002||p
PERL_MAGIC_vec|5.007002||p
PERL_MAGIC_vstring|5.008001||p
PERL_QUAD_MAX|5.004000||p
PERL_QUAD_MIN|5.004000||p
PERL_REVISION|5.006000||p
PERL_SCAN_ALLOW_UNDERSCORES|5.007003||p
PERL_SCAN_DISALLOW_PREFIX|5.007003||p
PERL_SCAN_GREATER_THAN_UV_MAX|5.007003||p
PERL_SCAN_SILENT_ILLDIGIT|5.008001||p
PERL_SHORT_MAX|5.004000||p
PERL_SHORT_MIN|5.004000||p
PERL_SIGNALS_UNSAFE_FLAG|5.008001||p
PERL_SUBVERSION|5.006000||p
PERL_UCHAR_MAX|5.004000||p
PERL_UCHAR_MIN|5.004000||p
PERL_UINT_MAX|5.004000||p
PERL_UINT_MIN|5.004000||p
PERL_ULONG_MAX|5.004000||p
PERL_ULONG_MIN|5.004000||p
PERL_UNUSED_ARG|5.009003||p
PERL_UNUSED_CONTEXT|5.009004||p
PERL_UNUSED_DECL|5.007002||p
PERL_UNUSED_VAR|5.007002||p
PERL_UQUAD_MAX|5.004000||p
PERL_UQUAD_MIN|5.004000||p
PERL_USE_GCC_BRACE_GROUPS|5.009004||p
PERL_USHORT_MAX|5.004000||p
PERL_USHORT_MIN|5.004000||p
PERL_VERSION|5.006000||p
PL_DBsignal|5.005000||p
PL_DBsingle|||pn
PL_DBsub|||pn
PL_DBtrace|||pn
PL_Sv|5.005000||p
PL_compiling|5.004050||p
PL_copline|5.009005||p
PL_curcop|5.004050||p
PL_curstash|5.004050||p
PL_debstash|5.004050||p
PL_defgv|5.004050||p
PL_diehook|5.004050||p
PL_dirty|5.004050||p
PL_dowarn|||pn
PL_errgv|5.004050||p
PL_expect|5.009005||p
PL_hexdigit|5.005000||p
PL_hints|5.005000||p
PL_last_in_gv|||n
PL_laststatval|5.005000||p
PL_modglobal||5.005000|n
PL_na|5.004050||pn
PL_no_modify|5.006000||p
PL_ofs_sv|||n
PL_perl_destruct_level|5.004050||p
PL_perldb|5.004050||p
PL_ppaddr|5.006000||p
PL_rsfp_filters|5.004050||p
PL_rsfp|5.004050||p
PL_rs|||n
PL_signals|5.008001||p
PL_stack_base|5.004050||p
PL_stack_sp|5.004050||p
PL_statcache|5.005000||p
PL_stdingv|5.004050||p
PL_sv_arenaroot|5.004050||p
PL_sv_no|5.004050||pn
PL_sv_undef|5.004050||pn
PL_sv_yes|5.004050||pn
PL_tainted|5.004050||p
PL_tainting|5.004050||p
POP_MULTICALL||5.009005|
POPi|||n
POPl|||n
POPn|||n
POPpbytex||5.007001|n
POPpx||5.005030|n
POPp|||n
POPs|||n
PTR2IV|5.006000||p
PTR2NV|5.006000||p
PTR2UV|5.006000||p
PTR2ul|5.007001||p
PTRV|5.006000||p
PUSHMARK|||
PUSH_MULTICALL||5.009005|
PUSHi|||
PUSHmortal|5.009002||p
PUSHn|||
PUSHp|||
PUSHs|||
PUSHu|5.004000||p
PUTBACK|||
PerlIO_clearerr||5.007003|
PerlIO_close||5.007003|
PerlIO_context_layers||5.009004|
PerlIO_eof||5.007003|
PerlIO_error||5.007003|
PerlIO_fileno||5.007003|
PerlIO_fill||5.007003|
PerlIO_flush||5.007003|
PerlIO_get_base||5.007003|
PerlIO_get_bufsiz||5.007003|
PerlIO_get_cnt||5.007003|
PerlIO_get_ptr||5.007003|
PerlIO_read||5.007003|
PerlIO_seek||5.007003|
PerlIO_set_cnt||5.007003|
PerlIO_set_ptrcnt||5.007003|
PerlIO_setlinebuf||5.007003|
PerlIO_stderr||5.007003|
PerlIO_stdin||5.007003|
PerlIO_stdout||5.007003|
PerlIO_tell||5.007003|
PerlIO_unread||5.007003|
PerlIO_write||5.007003|
Perl_signbit||5.009005|n
PoisonFree|5.009004||p
PoisonNew|5.009004||p
PoisonWith|5.009004||p
Poison|5.008000||p
RETVAL|||n
Renewc|||
Renew|||
SAVECLEARSV|||
SAVECOMPPAD|||
SAVEPADSV|||
SAVETMPS|||
SAVE_DEFSV|5.004050||p
SPAGAIN|||
SP|||
START_EXTERN_C|5.005000||p
START_MY_CXT|5.007003||p
STMT_END|||p
STMT_START|||p
STR_WITH_LEN|5.009003||p
ST|||
SV_CONST_RETURN|5.009003||p
SV_COW_DROP_PV|5.008001||p
SV_COW_SHARED_HASH_KEYS|5.009005||p
SV_GMAGIC|5.007002||p
SV_HAS_TRAILING_NUL|5.009004||p
SV_IMMEDIATE_UNREF|5.007001||p
SV_MUTABLE_RETURN|5.009003||p
SV_NOSTEAL|5.009002||p
SV_SMAGIC|5.009003||p
SV_UTF8_NO_ENCODING|5.008001||p
SVf|5.006000||p
SVt_IV|||
SVt_NV|||
SVt_PVAV|||
SVt_PVCV|||
SVt_PVHV|||
SVt_PVMG|||
SVt_PV|||
Safefree|||
Slab_Alloc|||
Slab_Free|||
Slab_to_rw|||
StructCopy|||
SvCUR_set|||
SvCUR|||
SvEND|||
SvGAMAGIC||5.006001|
SvGETMAGIC|5.004050||p
SvGROW|||
SvIOK_UV||5.006000|
SvIOK_notUV||5.006000|
SvIOK_off|||
SvIOK_only_UV||5.006000|
SvIOK_only|||
SvIOK_on|||
SvIOKp|||
SvIOK|||
SvIVX|||
SvIV_nomg|5.009001||p
SvIV_set|||
SvIVx|||
SvIV|||
SvIsCOW_shared_hash||5.008003|
SvIsCOW||5.008003|
SvLEN_set|||
SvLEN|||
SvLOCK||5.007003|
SvMAGIC_set|5.009003||p
SvNIOK_off|||
SvNIOKp|||
SvNIOK|||
SvNOK_off|||
SvNOK_only|||
SvNOK_on|||
SvNOKp|||
SvNOK|||
SvNVX|||
SvNV_set|||
SvNVx|||
SvNV|||
SvOK|||
SvOOK|||
SvPOK_off|||
SvPOK_only_UTF8||5.006000|
SvPOK_only|||
SvPOK_on|||
SvPOKp|||
SvPOK|||
SvPVX_const|5.009003||p
SvPVX_mutable|5.009003||p
SvPVX|||
SvPV_const|5.009003||p
SvPV_flags_const_nolen|5.009003||p
SvPV_flags_const|5.009003||p
SvPV_flags_mutable|5.009003||p
SvPV_flags|5.007002||p
SvPV_force_flags_mutable|5.009003||p
SvPV_force_flags_nolen|5.009003||p
SvPV_force_flags|5.007002||p
SvPV_force_mutable|5.009003||p
SvPV_force_nolen|5.009003||p
SvPV_force_nomg_nolen|5.009003||p
SvPV_force_nomg|5.007002||p
SvPV_force|||p
SvPV_mutable|5.009003||p
SvPV_nolen_const|5.009003||p
SvPV_nolen|5.006000||p
SvPV_nomg_const_nolen|5.009003||p
SvPV_nomg_const|5.009003||p
SvPV_nomg|5.007002||p
SvPV_set|||
SvPVbyte_force||5.009002|
SvPVbyte_nolen||5.006000|
SvPVbytex_force||5.006000|
SvPVbytex||5.006000|
SvPVbyte|5.006000||p
SvPVutf8_force||5.006000|
SvPVutf8_nolen||5.006000|
SvPVutf8x_force||5.006000|
SvPVutf8x||5.006000|
SvPVutf8||5.006000|
SvPVx|||
SvPV|||
SvREFCNT_dec|||
SvREFCNT_inc_NN|5.009004||p
SvREFCNT_inc_simple_NN|5.009004||p
SvREFCNT_inc_simple_void_NN|5.009004||p
SvREFCNT_inc_simple_void|5.009004||p
SvREFCNT_inc_simple|5.009004||p
SvREFCNT_inc_void_NN|5.009004||p
SvREFCNT_inc_void|5.009004||p
SvREFCNT_inc|||p
SvREFCNT|||
SvROK_off|||
SvROK_on|||
SvROK|||
SvRV_set|5.009003||p
SvRV|||
SvRXOK||5.009005|
SvRX||5.009005|
SvSETMAGIC|||
SvSHARED_HASH|5.009003||p
SvSHARE||5.007003|
SvSTASH_set|5.009003||p
SvSTASH|||
SvSetMagicSV_nosteal||5.004000|
SvSetMagicSV||5.004000|
SvSetSV_nosteal||5.004000|
SvSetSV|||
SvTAINTED_off||5.004000|
SvTAINTED_on||5.004000|
SvTAINTED||5.004000|
SvTAINT|||
SvTRUE|||
SvTYPE|||
SvUNLOCK||5.007003|
SvUOK|5.007001|5.006000|p
SvUPGRADE|||
SvUTF8_off||5.006000|
SvUTF8_on||5.006000|
SvUTF8||5.006000|
SvUVXx|5.004000||p
SvUVX|5.004000||p
SvUV_nomg|5.009001||p
SvUV_set|5.009003||p
SvUVx|5.004000||p
SvUV|5.004000||p
SvVOK||5.008001|
SvVSTRING_mg|5.009004||p
THIS|||n
UNDERBAR|5.009002||p
UTF8_MAXBYTES|5.009002||p
UVSIZE|5.006000||p
UVTYPE|5.006000||p
UVXf|5.007001||p
UVof|5.006000||p
UVuf|5.006000||p
UVxf|5.006000||p
WARN_ALL|5.006000||p
WARN_AMBIGUOUS|5.006000||p
WARN_ASSERTIONS|5.009005||p
WARN_BAREWORD|5.006000||p
WARN_CLOSED|5.006000||p
WARN_CLOSURE|5.006000||p
WARN_DEBUGGING|5.006000||p
WARN_DEPRECATED|5.006000||p
WARN_DIGIT|5.006000||p
WARN_EXEC|5.006000||p
WARN_EXITING|5.006000||p
WARN_GLOB|5.006000||p
WARN_INPLACE|5.006000||p
WARN_INTERNAL|5.006000||p
WARN_IO|5.006000||p
WARN_LAYER|5.008000||p
WARN_MALLOC|5.006000||p
WARN_MISC|5.006000||p
WARN_NEWLINE|5.006000||p
WARN_NUMERIC|5.006000||p
WARN_ONCE|5.006000||p
WARN_OVERFLOW|5.006000||p
WARN_PACK|5.006000||p
WARN_PARENTHESIS|5.006000||p
WARN_PIPE|5.006000||p
WARN_PORTABLE|5.006000||p
WARN_PRECEDENCE|5.006000||p
WARN_PRINTF|5.006000||p
WARN_PROTOTYPE|5.006000||p
WARN_QW|5.006000||p
WARN_RECURSION|5.006000||p
WARN_REDEFINE|5.006000||p
WARN_REGEXP|5.006000||p
WARN_RESERVED|5.006000||p
WARN_SEMICOLON|5.006000||p
WARN_SEVERE|5.006000||p
WARN_SIGNAL|5.006000||p
WARN_SUBSTR|5.006000||p
WARN_SYNTAX|5.006000||p
WARN_TAINT|5.006000||p
WARN_THREADS|5.008000||p
WARN_UNINITIALIZED|5.006000||p
WARN_UNOPENED|5.006000||p
WARN_UNPACK|5.006000||p
WARN_UNTIE|5.006000||p
WARN_UTF8|5.006000||p
WARN_VOID|5.006000||p
XCPT_CATCH|5.009002||p
XCPT_RETHROW|5.009002||p
XCPT_TRY_END|5.009002||p
XCPT_TRY_START|5.009002||p
XPUSHi|||
XPUSHmortal|5.009002||p
XPUSHn|||
XPUSHp|||
XPUSHs|||
XPUSHu|5.004000||p
XSRETURN_EMPTY|||
XSRETURN_IV|||
XSRETURN_NO|||
XSRETURN_NV|||
XSRETURN_PV|||
XSRETURN_UNDEF|||
XSRETURN_UV|5.008001||p
XSRETURN_YES|||
XSRETURN|||p
XST_mIV|||
XST_mNO|||
XST_mNV|||
XST_mPV|||
XST_mUNDEF|||
XST_mUV|5.008001||p
XST_mYES|||
XS_VERSION_BOOTCHECK|||
XS_VERSION|||
XSprePUSH|5.006000||p
XS|||
ZeroD|5.009002||p
Zero|||
_aMY_CXT|5.007003||p
_pMY_CXT|5.007003||p
aMY_CXT_|5.007003||p
aMY_CXT|5.007003||p
aTHXR_|5.009005||p
aTHXR|5.009005||p
aTHX_|5.006000||p
aTHX|5.006000||p
add_data|||n
addmad|||
allocmy|||
amagic_call|||
amagic_cmp_locale|||
amagic_cmp|||
amagic_i_ncmp|||
amagic_ncmp|||
any_dup|||
ao|||
append_elem|||
append_list|||
append_madprops|||
apply_attrs_my|||
apply_attrs_string||5.006001|
apply_attrs|||
apply|||
atfork_lock||5.007003|n
atfork_unlock||5.007003|n
av_arylen_p||5.009003|
av_clear|||
av_create_and_push||5.009005|
av_create_and_unshift_one||5.009005|
av_delete||5.006000|
av_exists||5.006000|
av_extend|||
av_fake|||
av_fetch|||
av_fill|||
av_len|||
av_make|||
av_pop|||
av_push|||
av_reify|||
av_shift|||
av_store|||
av_undef|||
av_unshift|||
ax|||n
bad_type|||
bind_match|||
block_end|||
block_gimme||5.004000|
block_start|||
boolSV|5.004000||p
boot_core_PerlIO|||
boot_core_UNIVERSAL|||
boot_core_mro|||
boot_core_xsutils|||
bytes_from_utf8||5.007001|
bytes_to_uni|||n
bytes_to_utf8||5.006001|
call_argv|5.006000||p
call_atexit||5.006000|
call_list||5.004000|
call_method|5.006000||p
call_pv|5.006000||p
call_sv|5.006000||p
calloc||5.007002|n
cando|||
cast_i32||5.006000|
cast_iv||5.006000|
cast_ulong||5.006000|
cast_uv||5.006000|
check_type_and_open|||
check_uni|||
checkcomma|||
checkposixcc|||
ckWARN|5.006000||p
ck_anoncode|||
ck_bitop|||
ck_concat|||
ck_defined|||
ck_delete|||
ck_die|||
ck_eof|||
ck_eval|||
ck_exec|||
ck_exists|||
ck_exit|||
ck_ftst|||
ck_fun|||
ck_glob|||
ck_grep|||
ck_index|||
ck_join|||
ck_lengthconst|||
ck_lfun|||
ck_listiob|||
ck_match|||
ck_method|||
ck_null|||
ck_open|||
ck_readline|||
ck_repeat|||
ck_require|||
ck_retarget|||
ck_return|||
ck_rfun|||
ck_rvconst|||
ck_sassign|||
ck_select|||
ck_shift|||
ck_sort|||
ck_spair|||
ck_split|||
ck_subr|||
ck_substr|||
ck_svconst|||
ck_trunc|||
ck_unpack|||
ckwarn_d||5.009003|
ckwarn||5.009003|
cl_and|||n
cl_anything|||n
cl_init_zero|||n
cl_init|||n
cl_is_anything|||n
cl_or|||n
clear_placeholders|||
closest_cop|||
convert|||
cop_free|||
cr_textfilter|||
create_eval_scope|||
croak_nocontext|||vn
croak|||v
csighandler||5.009003|n
curmad|||
custom_op_desc||5.007003|
custom_op_name||5.007003|
cv_ckproto_len|||
cv_ckproto|||
cv_clone|||
cv_const_sv||5.004000|
cv_dump|||
cv_undef|||
cx_dump||5.005000|
cx_dup|||
cxinc|||
dAXMARK|5.009003||p
dAX|5.007002||p
dITEMS|5.007002||p
dMARK|||
dMULTICALL||5.009003|
dMY_CXT_SV|5.007003||p
dMY_CXT|5.007003||p
dNOOP|5.006000||p
dORIGMARK|||
dSP|||
dTHR|5.004050||p
dTHXR|5.009005||p
dTHXa|5.006000||p
dTHXoa|5.006000||p
dTHX|5.006000||p
dUNDERBAR|5.009002||p
dVAR|5.009003||p
dXCPT|5.009002||p
dXSARGS|||
dXSI32|||
dXSTARG|5.006000||p
deb_curcv|||
deb_nocontext|||vn
deb_stack_all|||
deb_stack_n|||
debop||5.005000|
debprofdump||5.005000|
debprof|||
debstackptrs||5.007003|
debstack||5.007003|
debug_start_match|||
deb||5.007003|v
del_sv|||
delete_eval_scope|||
delimcpy||5.004000|
deprecate_old|||
deprecate|||
despatch_signals||5.007001|
destroy_matcher|||
die_nocontext|||vn
die_where|||
die|||v
dirp_dup|||
div128|||
djSP|||
do_aexec5|||
do_aexec|||
do_aspawn|||
do_binmode||5.004050|
do_chomp|||
do_chop|||
do_close|||
do_dump_pad|||
do_eof|||
do_exec3|||
do_execfree|||
do_exec|||
do_gv_dump||5.006000|
do_gvgv_dump||5.006000|
do_hv_dump||5.006000|
do_ipcctl|||
do_ipcget|||
do_join|||
do_kv|||
do_magic_dump||5.006000|
do_msgrcv|||
do_msgsnd|||
do_oddball|||
do_op_dump||5.006000|
do_op_xmldump|||
do_open9||5.006000|
do_openn||5.007001|
do_open||5.004000|
do_pipe|||
do_pmop_dump||5.006000|
do_pmop_xmldump|||
do_print|||
do_readline|||
do_seek|||
do_semop|||
do_shmio|||
do_smartmatch|||
do_spawn_nowait|||
do_spawn|||
do_sprintf|||
do_sv_dump||5.006000|
do_sysseek|||
do_tell|||
do_trans_complex_utf8|||
do_trans_complex|||
do_trans_count_utf8|||
do_trans_count|||
do_trans_simple_utf8|||
do_trans_simple|||
do_trans|||
do_vecget|||
do_vecset|||
do_vop|||
docatch_body|||
docatch|||
doeval|||
dofile|||
dofindlabel|||
doform|||
doing_taint||5.008001|n
dooneliner|||
doopen_pm|||
doparseform|||
dopoptoeval|||
dopoptogiven|||
dopoptolabel|||
dopoptoloop|||
dopoptosub_at|||
dopoptosub|||
dopoptowhen|||
doref||5.009003|
dounwind|||
dowantarray|||
dump_all||5.006000|
dump_eval||5.006000|
dump_exec_pos|||
dump_fds|||
dump_form||5.006000|
dump_indent||5.006000|v
dump_mstats|||
dump_packsubs||5.006000|
dump_sub||5.006000|
dump_sv_child|||
dump_trie_interim_list|||
dump_trie_interim_table|||
dump_trie|||
dump_vindent||5.006000|
dumpuntil|||
dup_attrlist|||
emulate_cop_io|||
emulate_eaccess|||
eval_pv|5.006000||p
eval_sv|5.006000||p
exec_failed|||
expect_number|||
fbm_compile||5.005000|
fbm_instr||5.005000|
fd_on_nosuid_fs|||
feature_is_enabled|||
filter_add|||
filter_del|||
filter_gets|||
filter_read|||
find_and_forget_pmops|||
find_array_subscript|||
find_beginning|||
find_byclass|||
find_hash_subscript|||
find_in_my_stash|||
find_runcv||5.008001|
find_rundefsvoffset||5.009002|
find_script|||
find_uninit_var|||
first_symbol|||n
fold_constants|||
forbid_setid|||
force_ident|||
force_list|||
force_next|||
force_version|||
force_word|||
forget_pmop|||
form_nocontext|||vn
form||5.004000|v
fp_dup|||
fprintf_nocontext|||vn
free_global_struct|||
free_tied_hv_pool|||
free_tmps|||
gen_constant_list|||
get_arena|||
get_av|5.006000||p
get_context||5.006000|n
get_cvn_flags||5.009005|
get_cv|5.006000||p
get_db_sub|||
get_debug_opts|||
get_hash_seed|||
get_hv|5.006000||p
get_mstats|||
get_no_modify|||
get_num|||
get_op_descs||5.005000|
get_op_names||5.005000|
get_opargs|||
get_ppaddr||5.006000|
get_re_arg|||
get_sv|5.006000||p
get_vtbl||5.005030|
getcwd_sv||5.007002|
getenv_len|||
glob_2number|||
glob_2pv|||
glob_assign_glob|||
glob_assign_ref|||
gp_dup|||
gp_free|||
gp_ref|||
grok_bin|5.007003||p
grok_hex|5.007003||p
grok_number|5.007002||p
grok_numeric_radix|5.007002||p
grok_oct|5.007003||p
group_end|||
gv_AVadd|||
gv_HVadd|||
gv_IOadd|||
gv_SVadd|||
gv_autoload4||5.004000|
gv_check|||
gv_const_sv||5.009003|
gv_dump||5.006000|
gv_efullname3||5.004000|
gv_efullname4||5.006001|
gv_efullname|||
gv_ename|||
gv_fetchfile_flags||5.009005|
gv_fetchfile|||
gv_fetchmeth_autoload||5.007003|
gv_fetchmethod_autoload||5.004000|
gv_fetchmethod|||
gv_fetchmeth|||
gv_fetchpvn_flags||5.009002|
gv_fetchpv|||
gv_fetchsv||5.009002|
gv_fullname3||5.004000|
gv_fullname4||5.006001|
gv_fullname|||
gv_handler||5.007001|
gv_init_sv|||
gv_init|||
gv_name_set||5.009004|
gv_stashpvn|5.004000||p
gv_stashpvs||5.009003|
gv_stashpv|||
gv_stashsv|||
he_dup|||
hek_dup|||
hfreeentries|||
hsplit|||
hv_assert||5.009005|
hv_auxinit|||n
hv_backreferences_p|||
hv_clear_placeholders||5.009001|
hv_clear|||
hv_copy_hints_hv|||
hv_delayfree_ent||5.004000|
hv_delete_common|||
hv_delete_ent||5.004000|
hv_delete|||
hv_eiter_p||5.009003|
hv_eiter_set||5.009003|
hv_exists_ent||5.004000|
hv_exists|||
hv_fetch_common|||
hv_fetch_ent||5.004000|
hv_fetchs|5.009003||p
hv_fetch|||
hv_free_ent||5.004000|
hv_iterinit|||
hv_iterkeysv||5.004000|
hv_iterkey|||
hv_iternext_flags||5.008000|
hv_iternextsv|||
hv_iternext|||
hv_iterval|||
hv_kill_backrefs|||
hv_ksplit||5.004000|
hv_magic_check|||n
hv_magic_uvar_xkey|||
hv_magic|||
hv_name_set||5.009003|
hv_notallowed|||
hv_placeholders_get||5.009003|
hv_placeholders_p||5.009003|
hv_placeholders_set||5.009003|
hv_riter_p||5.009003|
hv_riter_set||5.009003|
hv_scalar||5.009001|
hv_store_ent||5.004000|
hv_store_flags||5.008000|
hv_stores|5.009004||p
hv_store|||
hv_undef|||
ibcmp_locale||5.004000|
ibcmp_utf8||5.007003|
ibcmp|||
incl_perldb|||
incline|||
incpush_if_exists|||
incpush|||
ingroup|||
init_argv_symbols|||
init_debugger|||
init_global_struct|||
init_i18nl10n||5.006000|
init_i18nl14n||5.006000|
init_ids|||
init_interp|||
init_main_stash|||
init_perllib|||
init_postdump_symbols|||
init_predump_symbols|||
init_stacks||5.005000|
init_tm||5.007002|
instr|||
intro_my|||
intuit_method|||
intuit_more|||
invert|||
io_close|||
isALNUM|||
isALPHA|||
isDIGIT|||
isLOWER|||
isSPACE|||
isUPPER|||
is_an_int|||
is_gv_magical_sv|||
is_gv_magical|||
is_handle_constructor|||n
is_list_assignment|||
is_lvalue_sub||5.007001|
is_uni_alnum_lc||5.006000|
is_uni_alnumc_lc||5.006000|
is_uni_alnumc||5.006000|
is_uni_alnum||5.006000|
is_uni_alpha_lc||5.006000|
is_uni_alpha||5.006000|
is_uni_ascii_lc||5.006000|
is_uni_ascii||5.006000|
is_uni_cntrl_lc||5.006000|
is_uni_cntrl||5.006000|
is_uni_digit_lc||5.006000|
is_uni_digit||5.006000|
is_uni_graph_lc||5.006000|
is_uni_graph||5.006000|
is_uni_idfirst_lc||5.006000|
is_uni_idfirst||5.006000|
is_uni_lower_lc||5.006000|
is_uni_lower||5.006000|
is_uni_print_lc||5.006000|
is_uni_print||5.006000|
is_uni_punct_lc||5.006000|
is_uni_punct||5.006000|
is_uni_space_lc||5.006000|
is_uni_space||5.006000|
is_uni_upper_lc||5.006000|
is_uni_upper||5.006000|
is_uni_xdigit_lc||5.006000|
is_uni_xdigit||5.006000|
is_utf8_alnumc||5.006000|
is_utf8_alnum||5.006000|
is_utf8_alpha||5.006000|
is_utf8_ascii||5.006000|
is_utf8_char_slow|||n
is_utf8_char||5.006000|
is_utf8_cntrl||5.006000|
is_utf8_common|||
is_utf8_digit||5.006000|
is_utf8_graph||5.006000|
is_utf8_idcont||5.008000|
is_utf8_idfirst||5.006000|
is_utf8_lower||5.006000|
is_utf8_mark||5.006000|
is_utf8_print||5.006000|
is_utf8_punct||5.006000|
is_utf8_space||5.006000|
is_utf8_string_loclen||5.009003|
is_utf8_string_loc||5.008001|
is_utf8_string||5.006001|
is_utf8_upper||5.006000|
is_utf8_xdigit||5.006000|
isa_lookup|||
items|||n
ix|||n
jmaybe|||
join_exact|||
keyword|||
leave_scope|||
lex_end|||
lex_start|||
linklist|||
listkids|||
list|||
load_module_nocontext|||vn
load_module|5.006000||pv
localize|||
looks_like_bool|||
looks_like_number|||
lop|||
mPUSHi|5.009002||p
mPUSHn|5.009002||p
mPUSHp|5.009002||p
mPUSHu|5.009002||p
mXPUSHi|5.009002||p
mXPUSHn|5.009002||p
mXPUSHp|5.009002||p
mXPUSHu|5.009002||p
mad_free|||
madlex|||
madparse|||
magic_clear_all_env|||
magic_clearenv|||
magic_clearhint|||
magic_clearpack|||
magic_clearsig|||
magic_dump||5.006000|
magic_existspack|||
magic_freearylen_p|||
magic_freeovrld|||
magic_freeregexp|||
magic_getarylen|||
magic_getdefelem|||
magic_getnkeys|||
magic_getpack|||
magic_getpos|||
magic_getsig|||
magic_getsubstr|||
magic_gettaint|||
magic_getuvar|||
magic_getvec|||
magic_get|||
magic_killbackrefs|||
magic_len|||
magic_methcall|||
magic_methpack|||
magic_nextpack|||
magic_regdata_cnt|||
magic_regdatum_get|||
magic_regdatum_set|||
magic_scalarpack|||
magic_set_all_env|||
magic_setamagic|||
magic_setarylen|||
magic_setbm|||
magic_setcollxfrm|||
magic_setdbline|||
magic_setdefelem|||
magic_setenv|||
magic_setfm|||
magic_setglob|||
magic_sethint|||
magic_setisa|||
magic_setmglob|||
magic_setnkeys|||
magic_setpack|||
magic_setpos|||
magic_setregexp|||
magic_setsig|||
magic_setsubstr|||
magic_settaint|||
magic_setutf8|||
magic_setuvar|||
magic_setvec|||
magic_set|||
magic_sizepack|||
magic_wipepack|||
magicname|||
make_matcher|||
make_trie_failtable|||
make_trie|||
malloced_size|||n
malloc||5.007002|n
markstack_grow|||
matcher_matches_sv|||
measure_struct|||
memEQ|5.004000||p
memNE|5.004000||p
mem_collxfrm|||
mess_alloc|||
mess_nocontext|||vn
mess||5.006000|v
method_common|||
mfree||5.007002|n
mg_clear|||
mg_copy|||
mg_dup|||
mg_find|||
mg_free|||
mg_get|||
mg_length||5.005000|
mg_localize|||
mg_magical|||
mg_set|||
mg_size||5.005000|
mini_mktime||5.007002|
missingterm|||
mode_from_discipline|||
modkids|||
mod|||
more_bodies|||
more_sv|||
moreswitches|||
mro_get_linear_isa_c3||5.009005|
mro_get_linear_isa_dfs||5.009005|
mro_get_linear_isa||5.009005|
mro_isa_changed_in|||
mro_meta_dup|||
mro_meta_init|||
mro_method_changed_in||5.009005|
mul128|||
mulexp10|||n
my_atof2||5.007002|
my_atof||5.006000|
my_attrs|||
my_bcopy|||n
my_betoh16|||n
my_betoh32|||n
my_betoh64|||n
my_betohi|||n
my_betohl|||n
my_betohs|||n
my_bzero|||n
my_chsize|||
my_clearenv|||
my_cxt_index|||
my_cxt_init|||
my_dirfd||5.009005|
my_exit_jump|||
my_exit|||
my_failure_exit||5.004000|
my_fflush_all||5.006000|
my_fork||5.007003|n
my_htobe16|||n
my_htobe32|||n
my_htobe64|||n
my_htobei|||n
my_htobel|||n
my_htobes|||n
my_htole16|||n
my_htole32|||n
my_htole64|||n
my_htolei|||n
my_htolel|||n
my_htoles|||n
my_htonl|||
my_kid|||
my_letoh16|||n
my_letoh32|||n
my_letoh64|||n
my_letohi|||n
my_letohl|||n
my_letohs|||n
my_lstat|||
my_memcmp||5.004000|n
my_memset|||n
my_ntohl|||
my_pclose||5.004000|
my_popen_list||5.007001|
my_popen||5.004000|
my_setenv|||
my_snprintf|5.009004||pvn
my_socketpair||5.007003|n
my_sprintf||5.009003|vn
my_stat|||
my_strftime||5.007002|
my_strlcat|5.009004||pn
my_strlcpy|5.009004||pn
my_swabn|||n
my_swap|||
my_unexec|||
my_vsnprintf||5.009004|n
my|||
need_utf8|||n
newANONATTRSUB||5.006000|
newANONHASH|||
newANONLIST|||
newANONSUB|||
newASSIGNOP|||
newATTRSUB||5.006000|
newAVREF|||
newAV|||
newBINOP|||
newCONDOP|||
newCONSTSUB|5.004050||p
newCVREF|||
newDEFSVOP|||
newFORM|||
newFOROP|||
newGIVENOP||5.009003|
newGIVWHENOP|||
newGP|||
newGVOP|||
newGVREF|||
newGVgen|||
newHVREF|||
newHVhv||5.005000|
newHV|||
newIO|||
newLISTOP|||
newLOGOP|||
newLOOPEX|||
newLOOPOP|||
newMADPROP|||
newMADsv|||
newMYSUB|||
newNULLLIST|||
newOP|||
newPADOP|||
newPMOP|||
newPROG|||
newPVOP|||
newRANGE|||
newRV_inc|5.004000||p
newRV_noinc|5.004000||p
newRV|||
newSLICEOP|||
newSTATEOP|||
newSUB|||
newSVOP|||
newSVREF|||
newSV_type||5.009005|
newSVhek||5.009003|
newSViv|||
newSVnv|||
newSVpvf_nocontext|||vn
newSVpvf||5.004000|v
newSVpvn_share|5.007001||p
newSVpvn|5.004050||p
newSVpvs_share||5.009003|
newSVpvs|5.009003||p
newSVpv|||
newSVrv|||
newSVsv|||
newSVuv|5.006000||p
newSV|||
newTOKEN|||
newUNOP|||
newWHENOP||5.009003|
newWHILEOP||5.009003|
newXS_flags||5.009004|
newXSproto||5.006000|
newXS||5.006000|
new_collate||5.006000|
new_constant|||
new_ctype||5.006000|
new_he|||
new_logop|||
new_numeric||5.006000|
new_stackinfo||5.005000|
new_version||5.009000|
new_warnings_bitfield|||
next_symbol|||
nextargv|||
nextchar|||
ninstr|||
no_bareword_allowed|||
no_fh_allowed|||
no_op|||
not_a_number|||
nothreadhook||5.008000|
nuke_stacks|||
num_overflow|||n
offer_nice_chunk|||
oopsAV|||
oopsCV|||
oopsHV|||
op_clear|||
op_const_sv|||
op_dump||5.006000|
op_free|||
op_getmad_weak|||
op_getmad|||
op_null||5.007002|
op_refcnt_dec|||
op_refcnt_inc|||
op_refcnt_lock||5.009002|
op_refcnt_unlock||5.009002|
op_xmldump|||
open_script|||
pMY_CXT_|5.007003||p
pMY_CXT|5.007003||p
pTHX_|5.006000||p
pTHX|5.006000||p
packWARN|5.007003||p
pack_cat||5.007003|
pack_rec|||
package|||
packlist||5.008001|
pad_add_anon|||
pad_add_name|||
pad_alloc|||
pad_block_start|||
pad_check_dup|||
pad_compname_type|||
pad_findlex|||
pad_findmy|||
pad_fixup_inner_anons|||
pad_free|||
pad_leavemy|||
pad_new|||
pad_peg|||n
pad_push|||
pad_reset|||
pad_setsv|||
pad_sv||5.009005|
pad_swipe|||
pad_tidy|||
pad_undef|||
parse_body|||
parse_unicode_opts|||
parser_dup|||
parser_free|||
path_is_absolute|||n
peep|||
pending_Slabs_to_ro|||
perl_alloc_using|||n
perl_alloc|||n
perl_clone_using|||n
perl_clone|||n
perl_construct|||n
perl_destruct||5.007003|n
perl_free|||n
perl_parse||5.006000|n
perl_run|||n
pidgone|||
pm_description|||
pmflag|||
pmop_dump||5.006000|
pmop_xmldump|||
pmruntime|||
pmtrans|||
pop_scope|||
pregcomp||5.009005|
pregexec|||
pregfree|||
prepend_elem|||
prepend_madprops|||
printbuf|||
printf_nocontext|||vn
process_special_blocks|||
ptr_table_clear||5.009005|
ptr_table_fetch||5.009005|
ptr_table_find|||n
ptr_table_free||5.009005|
ptr_table_new||5.009005|
ptr_table_split||5.009005|
ptr_table_store||5.009005|
push_scope|||
put_byte|||
pv_display||5.006000|
pv_escape||5.009004|
pv_pretty||5.009004|
pv_uni_display||5.007003|
qerror|||
qsortsvu|||
re_compile||5.009005|
re_croak2|||
re_dup|||
re_intuit_start||5.009005|
re_intuit_string||5.006000|
readpipe_override|||
realloc||5.007002|n
reentrant_free|||
reentrant_init|||
reentrant_retry|||vn
reentrant_size|||
ref_array_or_hash|||
refcounted_he_chain_2hv|||
refcounted_he_fetch|||
refcounted_he_free|||
refcounted_he_new|||
refcounted_he_value|||
refkids|||
refto|||
ref||5.009003|
reg_check_named_buff_matched|||
reg_named_buff_all||5.009005|
reg_named_buff_exists||5.009005|
reg_named_buff_fetch||5.009005|
reg_named_buff_firstkey||5.009005|
reg_named_buff_iter|||
reg_named_buff_nextkey||5.009005|
reg_named_buff_scalar||5.009005|
reg_named_buff|||
reg_namedseq|||
reg_node|||
reg_numbered_buff_fetch|||
reg_numbered_buff_length|||
reg_numbered_buff_store|||
reg_qr_package|||
reg_recode|||
reg_scan_name|||
reg_skipcomment|||
reg_stringify||5.009005|
reg_temp_copy|||
reganode|||
regatom|||
regbranch|||
regclass_swash||5.009004|
regclass|||
regcppop|||
regcppush|||
regcurly|||n
regdump_extflags|||
regdump||5.005000|
regdupe_internal|||
regexec_flags||5.005000|
regfree_internal||5.009005|
reghop3|||n
reghop4|||n
reghopmaybe3|||n
reginclass|||
reginitcolors||5.006000|
reginsert|||
regmatch|||
regnext||5.005000|
regpiece|||
regpposixcc|||
regprop|||
regrepeat|||
regtail_study|||
regtail|||
regtry|||
reguni|||
regwhite|||n
reg|||
repeatcpy|||
report_evil_fh|||
report_uninit|||
require_pv||5.006000|
require_tie_mod|||
restore_magic|||
rninstr|||
rsignal_restore|||
rsignal_save|||
rsignal_state||5.004000|
rsignal||5.004000|
run_body|||
run_user_filter|||
runops_debug||5.005000|
runops_standard||5.005000|
rvpv_dup|||
rxres_free|||
rxres_restore|||
rxres_save|||
safesyscalloc||5.006000|n
safesysfree||5.006000|n
safesysmalloc||5.006000|n
safesysrealloc||5.006000|n
same_dirent|||
save_I16||5.004000|
save_I32|||
save_I8||5.006000|
save_aelem||5.004050|
save_alloc||5.006000|
save_aptr|||
save_ary|||
save_bool||5.008001|
save_clearsv|||
save_delete|||
save_destructor_x||5.006000|
save_destructor||5.006000|
save_freeop|||
save_freepv|||
save_freesv|||
save_generic_pvref||5.006001|
save_generic_svref||5.005030|
save_gp||5.004000|
save_hash|||
save_hek_flags|||n
save_helem||5.004050|
save_hints||5.005000|
save_hptr|||
save_int|||
save_item|||
save_iv||5.005000|
save_lines|||
save_list|||
save_long|||
save_magic|||
save_mortalizesv||5.007001|
save_nogv|||
save_op|||
save_padsv||5.007001|
save_pptr|||
save_re_context||5.006000|
save_scalar_at|||
save_scalar|||
save_set_svflags||5.009000|
save_shared_pvref||5.007003|
save_sptr|||
save_svref|||
save_vptr||5.006000|
savepvn|||
savepvs||5.009003|
savepv|||
savesharedpvn||5.009005|
savesharedpv||5.007003|
savestack_grow_cnt||5.008001|
savestack_grow|||
savesvpv||5.009002|
sawparens|||
scalar_mod_type|||n
scalarboolean|||
scalarkids|||
scalarseq|||
scalarvoid|||
scalar|||
scan_bin||5.006000|
scan_commit|||
scan_const|||
scan_formline|||
scan_heredoc|||
scan_hex|||
scan_ident|||
scan_inputsymbol|||
scan_num||5.007001|
scan_oct|||
scan_pat|||
scan_str|||
scan_subst|||
scan_trans|||
scan_version||5.009001|
scan_vstring||5.009005|
scan_word|||
scope|||
screaminstr||5.005000|
seed||5.008001|
sequence_num|||
sequence_tail|||
sequence|||
set_context||5.006000|n
set_csh|||
set_numeric_local||5.006000|
set_numeric_radix||5.006000|
set_numeric_standard||5.006000|
setdefout|||
setenv_getix|||
share_hek_flags|||
share_hek||5.004000|
si_dup|||
sighandler|||n
simplify_sort|||
skipspace0|||
skipspace1|||
skipspace2|||
skipspace|||
softref2xv|||
sortcv_stacked|||
sortcv_xsub|||
sortcv|||
sortsv_flags||5.009003|
sortsv||5.007003|
space_join_names_mortal|||
ss_dup|||
stack_grow|||
start_force|||
start_glob|||
start_subparse||5.004000|
stashpv_hvname_match||5.009005|
stdize_locale|||
strEQ|||
strGE|||
strGT|||
strLE|||
strLT|||
strNE|||
str_to_version||5.006000|
strip_return|||
strnEQ|||
strnNE|||
study_chunk|||
sub_crush_depth|||
sublex_done|||
sublex_push|||
sublex_start|||
sv_2bool|||
sv_2cv|||
sv_2io|||
sv_2iuv_common|||
sv_2iuv_non_preserve|||
sv_2iv_flags||5.009001|
sv_2iv|||
sv_2mortal|||
sv_2nv|||
sv_2pv_flags|5.007002||p
sv_2pv_nolen|5.006000||p
sv_2pvbyte_nolen|5.006000||p
sv_2pvbyte|5.006000||p
sv_2pvutf8_nolen||5.006000|
sv_2pvutf8||5.006000|
sv_2pv|||
sv_2uv_flags||5.009001|
sv_2uv|5.004000||p
sv_add_arena|||
sv_add_backref|||
sv_backoff|||
sv_bless|||
sv_cat_decode||5.008001|
sv_catpv_mg|5.004050||p
sv_catpvf_mg_nocontext|||pvn
sv_catpvf_mg|5.006000|5.004000|pv
sv_catpvf_nocontext|||vn
sv_catpvf||5.004000|v
sv_catpvn_flags||5.007002|
sv_catpvn_mg|5.004050||p
sv_catpvn_nomg|5.007002||p
sv_catpvn|||
sv_catpvs|5.009003||p
sv_catpv|||
sv_catsv_flags||5.007002|
sv_catsv_mg|5.004050||p
sv_catsv_nomg|5.007002||p
sv_catsv|||
sv_catxmlpvn|||
sv_catxmlsv|||
sv_chop|||
sv_clean_all|||
sv_clean_objs|||
sv_clear|||
sv_cmp_locale||5.004000|
sv_cmp|||
sv_collxfrm|||
sv_compile_2op||5.008001|
sv_copypv||5.007003|
sv_dec|||
sv_del_backref|||
sv_derived_from||5.004000|
sv_does||5.009004|
sv_dump|||
sv_dup|||
sv_eq|||
sv_exp_grow|||
sv_force_normal_flags||5.007001|
sv_force_normal||5.006000|
sv_free2|||
sv_free_arenas|||
sv_free|||
sv_gets||5.004000|
sv_grow|||
sv_i_ncmp|||
sv_inc|||
sv_insert|||
sv_isa|||
sv_isobject|||
sv_iv||5.005000|
sv_kill_backrefs|||
sv_len_utf8||5.006000|
sv_len|||
sv_magic_portable|5.009005|5.004000|p
sv_magicext||5.007003|
sv_magic|||
sv_mortalcopy|||
sv_ncmp|||
sv_newmortal|||
sv_newref|||
sv_nolocking||5.007003|
sv_nosharing||5.007003|
sv_nounlocking|||
sv_nv||5.005000|
sv_peek||5.005000|
sv_pos_b2u_midway|||
sv_pos_b2u||5.006000|
sv_pos_u2b_cached|||
sv_pos_u2b_forwards|||n
sv_pos_u2b_midway|||n
sv_pos_u2b||5.006000|
sv_pvbyten_force||5.006000|
sv_pvbyten||5.006000|
sv_pvbyte||5.006000|
sv_pvn_force_flags|5.007002||p
sv_pvn_force|||
sv_pvn_nomg|5.007003||p
sv_pvn|||
sv_pvutf8n_force||5.006000|
sv_pvutf8n||5.006000|
sv_pvutf8||5.006000|
sv_pv||5.006000|
sv_recode_to_utf8||5.007003|
sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
sv_setpvf_mg_nocontext|||pvn
sv_setpvf_mg|5.006000|5.004000|pv
sv_setpvf_nocontext|||vn
sv_setpvf||5.004000|v
sv_setpviv_mg||5.008001|
sv_setpviv||5.008001|
sv_setpvn_mg|5.004050||p
sv_setpvn|||
sv_setpvs|5.009004||p
sv_setpv|||
sv_setref_iv|||
sv_setref_nv|||
sv_setref_pvn|||
sv_setref_pv|||
sv_setref_uv||5.007001|
sv_setsv_cow|||
sv_setsv_flags||5.007002|
sv_setsv_mg|5.004050||p
sv_setsv_nomg|5.007002||p
sv_setsv|||
sv_setuv_mg|5.004050||p
sv_setuv|5.004000||p
sv_tainted||5.004000|
sv_taint||5.004000|
sv_true||5.005000|
sv_unglob|||
sv_uni_display||5.007003|
sv_unmagic|||
sv_unref_flags||5.007001|
sv_unref|||
sv_untaint||5.004000|
sv_upgrade|||
sv_usepvn_flags||5.009004|
sv_usepvn_mg|5.004050||p
sv_usepvn|||
sv_utf8_decode||5.006000|
sv_utf8_downgrade||5.006000|
sv_utf8_encode||5.006000|
sv_utf8_upgrade_flags||5.007002|
sv_utf8_upgrade||5.007001|
sv_uv|5.005000||p
sv_vcatpvf_mg|5.006000|5.004000|p
sv_vcatpvfn||5.004000|
sv_vcatpvf|5.006000|5.004000|p
sv_vsetpvf_mg|5.006000|5.004000|p
sv_vsetpvfn||5.004000|
sv_vsetpvf|5.006000|5.004000|p
sv_xmlpeek|||
svtype|||
swallow_bom|||
swap_match_buff|||
swash_fetch||5.007002|
swash_get|||
swash_init||5.006000|
sys_intern_clear|||
sys_intern_dup|||
sys_intern_init|||
taint_env|||
taint_proper|||
tmps_grow||5.006000|
toLOWER|||
toUPPER|||
to_byte_substr|||
to_uni_fold||5.007003|
to_uni_lower_lc||5.006000|
to_uni_lower||5.007003|
to_uni_title_lc||5.006000|
to_uni_title||5.007003|
to_uni_upper_lc||5.006000|
to_uni_upper||5.007003|
to_utf8_case||5.007003|
to_utf8_fold||5.007003|
to_utf8_lower||5.007003|
to_utf8_substr|||
to_utf8_title||5.007003|
to_utf8_upper||5.007003|
token_free|||
token_getmad|||
tokenize_use|||
tokeq|||
tokereport|||
too_few_arguments|||
too_many_arguments|||
uiv_2buf|||n
unlnk|||
unpack_rec|||
unpack_str||5.007003|
unpackstring||5.008001|
unshare_hek_or_pvn|||
unshare_hek|||
unsharepvn||5.004000|
unwind_handler_stack|||
update_debugger_info|||
upg_version||5.009005|
usage|||
utf16_to_utf8_reversed||5.006001|
utf16_to_utf8||5.006001|
utf8_distance||5.006000|
utf8_hop||5.006000|
utf8_length||5.007001|
utf8_mg_pos_cache_update|||
utf8_to_bytes||5.006001|
utf8_to_uvchr||5.007001|
utf8_to_uvuni||5.007001|
utf8n_to_uvchr|||
utf8n_to_uvuni||5.007001|
utilize|||
uvchr_to_utf8_flags||5.007003|
uvchr_to_utf8|||
uvuni_to_utf8_flags||5.007003|
uvuni_to_utf8||5.007001|
validate_suid|||
varname|||
vcmp||5.009000|
vcroak||5.006000|
vdeb||5.007003|
vdie_common|||
vdie_croak_common|||
vdie|||
vform||5.006000|
visit|||
vivify_defelem|||
vivify_ref|||
vload_module|5.006000||p
vmess||5.006000|
vnewSVpvf|5.006000|5.004000|p
vnormal||5.009002|
vnumify||5.009000|
vstringify||5.009000|
vverify||5.009003|
vwarner||5.006000|
vwarn||5.006000|
wait4pid|||
warn_nocontext|||vn
warner_nocontext|||vn
warner|5.006000|5.004000|pv
warn|||v
watch|||
whichsig|||
write_no_mem|||
write_to_stderr|||
xmldump_all|||
xmldump_attr|||
xmldump_eval|||
xmldump_form|||
xmldump_indent|||v
xmldump_packsubs|||
xmldump_sub|||
xmldump_vindent|||
yyerror|||
yylex|||
yyparse|||
yywarn|||
);
if (exists $opt{'list-unsupported'}) {
my $f;
for $f (sort { lc $a cmp lc $b } keys %API) {
next unless $API{$f}{todo};
print "$f ", '.'x(40-length($f)), " ", format_version($API{$f}{todo}), "\n";
}
exit 0;
}
# Scan for possible replacement candidates
my(%replace, %need, %hints, %warnings, %depends);
my $replace = 0;
my($hint, $define, $function);
sub find_api
{
my $code = shift;
$code =~ s{
/ (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]*)
| "[^"\\]*(?:\\.[^"\\]*)*"
| '[^'\\]*(?:\\.[^'\\]*)*' }{}egsx;
grep { exists $API{$_} } $code =~ /(\w+)/mg;
}
while () {
if ($hint) {
my $h = $hint->[0] eq 'Hint' ? \%hints : \%warnings;
if (m{^\s*\*\s(.*?)\s*$}) {
for (@{$hint->[1]}) {
$h->{$_} ||= ''; # suppress warning with older perls
$h->{$_} .= "$1\n";
}
}
else { undef $hint }
}
$hint = [$1, [split /,?\s+/, $2]]
if m{^\s*$rccs\s+(Hint|Warning):\s+(\w+(?:,?\s+\w+)*)\s*$};
if ($define) {
if ($define->[1] =~ /\\$/) {
$define->[1] .= $_;
}
else {
if (exists $API{$define->[0]} && $define->[1] !~ /^DPPP_\(/) {
my @n = find_api($define->[1]);
push @{$depends{$define->[0]}}, @n if @n
}
undef $define;
}
}
$define = [$1, $2] if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(.*)};
if ($function) {
if (/^}/) {
if (exists $API{$function->[0]}) {
my @n = find_api($function->[1]);
push @{$depends{$function->[0]}}, @n if @n
}
undef $define;
}
else {
$function->[1] .= $_;
}
}
$function = [$1, ''] if m{^DPPP_\(my_(\w+)\)};
$replace = $1 if m{^\s*$rccs\s+Replace:\s+(\d+)\s+$rcce\s*$};
$replace{$2} = $1 if $replace and m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+)};
$replace{$2} = $1 if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+).*$rccs\s+Replace\s+$rcce};
$replace{$1} = $2 if m{^\s*$rccs\s+Replace (\w+) with (\w+)\s+$rcce\s*$};
if (m{^\s*$rccs\s+(\w+)\s+depends\s+on\s+(\w+(\s*,\s*\w+)*)\s+$rcce\s*$}) {
push @{$depends{$1}}, map { s/\s+//g; $_ } split /,/, $2;
}
$need{$1} = 1 if m{^#if\s+defined\(NEED_(\w+)(?:_GLOBAL)?\)};
}
for (values %depends) {
my %s;
$_ = [sort grep !$s{$_}++, @$_];
}
if (exists $opt{'api-info'}) {
my $f;
my $count = 0;
my $match = $opt{'api-info'} =~ m!^/(.*)/$! ? $1 : "^\Q$opt{'api-info'}\E\$";
for $f (sort { lc $a cmp lc $b } keys %API) {
next unless $f =~ /$match/;
print "\n=== $f ===\n\n";
my $info = 0;
if ($API{$f}{base} || $API{$f}{todo}) {
my $base = format_version($API{$f}{base} || $API{$f}{todo});
print "Supported at least starting from perl-$base.\n";
$info++;
}
if ($API{$f}{provided}) {
my $todo = $API{$f}{todo} ? format_version($API{$f}{todo}) : "5.003";
print "Support by $ppport provided back to perl-$todo.\n";
print "Support needs to be explicitly requested by NEED_$f.\n" if exists $need{$f};
print "Depends on: ", join(', ', @{$depends{$f}}), ".\n" if exists $depends{$f};
print "\n$hints{$f}" if exists $hints{$f};
print "\nWARNING:\n$warnings{$f}" if exists $warnings{$f};
$info++;
}
print "No portability information available.\n" unless $info;
$count++;
}
$count or print "Found no API matching '$opt{'api-info'}'.";
print "\n";
exit 0;
}
if (exists $opt{'list-provided'}) {
my $f;
for $f (sort { lc $a cmp lc $b } keys %API) {
next unless $API{$f}{provided};
my @flags;
push @flags, 'explicit' if exists $need{$f};
push @flags, 'depend' if exists $depends{$f};
push @flags, 'hint' if exists $hints{$f};
push @flags, 'warning' if exists $warnings{$f};
my $flags = @flags ? ' ['.join(', ', @flags).']' : '';
print "$f$flags\n";
}
exit 0;
}
my @files;
my @srcext = qw( .xs .c .h .cc .cpp -c.inc -xs.inc );
my $srcext = join '|', map { quotemeta $_ } @srcext;
if (@ARGV) {
my %seen;
for (@ARGV) {
if (-e) {
if (-f) {
push @files, $_ unless $seen{$_}++;
}
else { warn "'$_' is not a file.\n" }
}
else {
my @new = grep { -f } glob $_
or warn "'$_' does not exist.\n";
push @files, grep { !$seen{$_}++ } @new;
}
}
}
else {
eval {
require File::Find;
File::Find::find(sub {
$File::Find::name =~ /($srcext)$/i
and push @files, $File::Find::name;
}, '.');
};
if ($@) {
@files = map { glob "*$_" } @srcext;
}
}
if (!@ARGV || $opt{filter}) {
my(@in, @out);
my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files;
for (@files) {
my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i;
push @{ $out ? \@out : \@in }, $_;
}
if (@ARGV && @out) {
warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out);
}
@files = @in;
}
die "No input files given!\n" unless @files;
my(%files, %global, %revreplace);
%revreplace = reverse %replace;
my $filename;
my $patch_opened = 0;
for $filename (@files) {
unless (open IN, "<$filename") {
warn "Unable to read from $filename: $!\n";
next;
}
info("Scanning $filename ...");
my $c = do { local $/; };
close IN;
my %file = (orig => $c, changes => 0);
# Temporarily remove C/XS comments and strings from the code
my @ccom;
$c =~ s{
( ^$HS*\#$HS*include\b[^\r\n]+\b(?:\Q$ppport\E|XSUB\.h)\b[^\r\n]*
| ^$HS*\#$HS*(?:define|elif|if(?:def)?)\b[^\r\n]* )
| ( ^$HS*\#[^\r\n]*
| "[^"\\]*(?:\\.[^"\\]*)*"
| '[^'\\]*(?:\\.[^'\\]*)*'
| / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]* ) )
}{ defined $2 and push @ccom, $2;
defined $1 ? $1 : "$ccs$#ccom$cce" }mgsex;
$file{ccom} = \@ccom;
$file{code} = $c;
$file{has_inc_ppport} = $c =~ /^$HS*#$HS*include[^\r\n]+\b\Q$ppport\E\b/m;
my $func;
for $func (keys %API) {
my $match = $func;
$match .= "|$revreplace{$func}" if exists $revreplace{$func};
if ($c =~ /\b(?:Perl_)?($match)\b/) {
$file{uses_replace}{$1}++ if exists $revreplace{$func} && $1 eq $revreplace{$func};
$file{uses_Perl}{$func}++ if $c =~ /\bPerl_$func\b/;
if (exists $API{$func}{provided}) {
$file{uses_provided}{$func}++;
if (!exists $API{$func}{base} || $API{$func}{base} > $opt{'compat-version'}) {
$file{uses}{$func}++;
my @deps = rec_depend($func);
if (@deps) {
$file{uses_deps}{$func} = \@deps;
for (@deps) {
$file{uses}{$_} = 0 unless exists $file{uses}{$_};
}
}
for ($func, @deps) {
$file{needs}{$_} = 'static' if exists $need{$_};
}
}
}
if (exists $API{$func}{todo} && $API{$func}{todo} > $opt{'compat-version'}) {
if ($c =~ /\b$func\b/) {
$file{uses_todo}{$func}++;
}
}
}
}
while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) {
if (exists $need{$2}) {
$file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++;
}
else { warning("Possibly wrong #define $1 in $filename") }
}
for (qw(uses needs uses_todo needed_global needed_static)) {
for $func (keys %{$file{$_}}) {
push @{$global{$_}{$func}}, $filename;
}
}
$files{$filename} = \%file;
}
# Globally resolve NEED_'s
my $need;
for $need (keys %{$global{needs}}) {
if (@{$global{needs}{$need}} > 1) {
my @targets = @{$global{needs}{$need}};
my @t = grep $files{$_}{needed_global}{$need}, @targets;
@targets = @t if @t;
@t = grep /\.xs$/i, @targets;
@targets = @t if @t;
my $target = shift @targets;
$files{$target}{needs}{$need} = 'global';
for (@{$global{needs}{$need}}) {
$files{$_}{needs}{$need} = 'extern' if $_ ne $target;
}
}
}
for $filename (@files) {
exists $files{$filename} or next;
info("=== Analyzing $filename ===");
my %file = %{$files{$filename}};
my $func;
my $c = $file{code};
my $warnings = 0;
for $func (sort keys %{$file{uses_Perl}}) {
if ($API{$func}{varargs}) {
unless ($API{$func}{nothxarg}) {
my $changes = ($c =~ s{\b(Perl_$func\s*\(\s*)(?!aTHX_?)(\)|[^\s)]*\))}
{ $1 . ($2 eq ')' ? 'aTHX' : 'aTHX_ ') . $2 }ge);
if ($changes) {
warning("Doesn't pass interpreter argument aTHX to Perl_$func");
$file{changes} += $changes;
}
}
}
else {
warning("Uses Perl_$func instead of $func");
$file{changes} += ($c =~ s{\bPerl_$func(\s*)\((\s*aTHX_?)?\s*}
{$func$1(}g);
}
}
for $func (sort keys %{$file{uses_replace}}) {
warning("Uses $func instead of $replace{$func}");
$file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g);
}
for $func (sort keys %{$file{uses_provided}}) {
if ($file{uses}{$func}) {
if (exists $file{uses_deps}{$func}) {
diag("Uses $func, which depends on ", join(', ', @{$file{uses_deps}{$func}}));
}
else {
diag("Uses $func");
}
}
$warnings += hint($func);
}
unless ($opt{quiet}) {
for $func (sort keys %{$file{uses_todo}}) {
print "*** WARNING: Uses $func, which may not be portable below perl ",
format_version($API{$func}{todo}), ", even with '$ppport'\n";
$warnings++;
}
}
for $func (sort keys %{$file{needed_static}}) {
my $message = '';
if (not exists $file{uses}{$func}) {
$message = "No need to define NEED_$func if $func is never used";
}
elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') {
$message = "No need to define NEED_$func when already needed globally";
}
if ($message) {
diag($message);
$file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg);
}
}
for $func (sort keys %{$file{needed_global}}) {
my $message = '';
if (not exists $global{uses}{$func}) {
$message = "No need to define NEED_${func}_GLOBAL if $func is never used";
}
elsif (exists $file{needs}{$func}) {
if ($file{needs}{$func} eq 'extern') {
$message = "No need to define NEED_${func}_GLOBAL when already needed globally";
}
elsif ($file{needs}{$func} eq 'static') {
$message = "No need to define NEED_${func}_GLOBAL when only used in this file";
}
}
if ($message) {
diag($message);
$file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg);
}
}
$file{needs_inc_ppport} = keys %{$file{uses}};
if ($file{needs_inc_ppport}) {
my $pp = '';
for $func (sort keys %{$file{needs}}) {
my $type = $file{needs}{$func};
next if $type eq 'extern';
my $suffix = $type eq 'global' ? '_GLOBAL' : '';
unless (exists $file{"needed_$type"}{$func}) {
if ($type eq 'global') {
diag("Files [@{$global{needs}{$func}}] need $func, adding global request");
}
else {
diag("File needs $func, adding static request");
}
$pp .= "#define NEED_$func$suffix\n";
}
}
if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) {
$pp = '';
$file{changes}++;
}
unless ($file{has_inc_ppport}) {
diag("Needs to include '$ppport'");
$pp .= qq(#include "$ppport"\n)
}
if ($pp) {
$file{changes} += ($c =~ s/^($HS*#$HS*define$HS+NEED_\w+.*?)^/$1$pp/ms)
|| ($c =~ s/^(?=$HS*#$HS*include.*\Q$ppport\E)/$pp/m)
|| ($c =~ s/^($HS*#$HS*include.*XSUB.*\s*?)^/$1$pp/m)
|| ($c =~ s/^/$pp/);
}
}
else {
if ($file{has_inc_ppport}) {
diag("No need to include '$ppport'");
$file{changes} += ($c =~ s/^$HS*?#$HS*include.*\Q$ppport\E.*?$LF//m);
}
}
# put back in our C comments
my $ix;
my $cppc = 0;
my @ccom = @{$file{ccom}};
for $ix (0 .. $#ccom) {
if (!$opt{cplusplus} && $ccom[$ix] =~ s!^//!!) {
$cppc++;
$file{changes} += $c =~ s/$rccs$ix$rcce/$ccs$ccom[$ix] $cce/;
}
else {
$c =~ s/$rccs$ix$rcce/$ccom[$ix]/;
}
}
if ($cppc) {
my $s = $cppc != 1 ? 's' : '';
warning("Uses $cppc C++ style comment$s, which is not portable");
}
my $s = $warnings != 1 ? 's' : '';
my $warn = $warnings ? " ($warnings warning$s)" : '';
info("Analysis completed$warn");
if ($file{changes}) {
if (exists $opt{copy}) {
my $newfile = "$filename$opt{copy}";
if (-e $newfile) {
error("'$newfile' already exists, refusing to write copy of '$filename'");
}
else {
local *F;
if (open F, ">$newfile") {
info("Writing copy of '$filename' with changes to '$newfile'");
print F $c;
close F;
}
else {
error("Cannot open '$newfile' for writing: $!");
}
}
}
elsif (exists $opt{patch} || $opt{changes}) {
if (exists $opt{patch}) {
unless ($patch_opened) {
if (open PATCH, ">$opt{patch}") {
$patch_opened = 1;
}
else {
error("Cannot open '$opt{patch}' for writing: $!");
delete $opt{patch};
$opt{changes} = 1;
goto fallback;
}
}
mydiff(\*PATCH, $filename, $c);
}
else {
fallback:
info("Suggested changes:");
mydiff(\*STDOUT, $filename, $c);
}
}
else {
my $s = $file{changes} == 1 ? '' : 's';
info("$file{changes} potentially required change$s detected");
}
}
else {
info("Looks good");
}
}
close PATCH if $patch_opened;
exit 0;
sub try_use { eval "use @_;"; return $@ eq '' }
sub mydiff
{
local *F = shift;
my($file, $str) = @_;
my $diff;
if (exists $opt{diff}) {
$diff = run_diff($opt{diff}, $file, $str);
}
if (!defined $diff and try_use('Text::Diff')) {
$diff = Text::Diff::diff($file, \$str, { STYLE => 'Unified' });
$diff = <$tmp") {
print F $str;
close F;
if (open F, "$prog $file $tmp |") {
while () {
s/\Q$tmp\E/$file.patched/;
$diff .= $_;
}
close F;
unlink $tmp;
return $diff;
}
unlink $tmp;
}
else {
error("Cannot open '$tmp' for writing: $!");
}
return undef;
}
sub rec_depend
{
my($func, $seen) = @_;
return () unless exists $depends{$func};
$seen = {%{$seen||{}}};
return () if $seen->{$func}++;
my %s;
grep !$s{$_}++, map { ($_, rec_depend($_, $seen)) } @{$depends{$func}};
}
sub parse_version
{
my $ver = shift;
if ($ver =~ /^(\d+)\.(\d+)\.(\d+)$/) {
return ($1, $2, $3);
}
elsif ($ver !~ /^\d+\.[\d_]+$/) {
die "cannot parse version '$ver'\n";
}
$ver =~ s/_//g;
$ver =~ s/$/000000/;
my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/;
$v = int $v;
$s = int $s;
if ($r < 5 || ($r == 5 && $v < 6)) {
if ($s % 10) {
die "cannot parse version '$ver'\n";
}
}
return ($r, $v, $s);
}
sub format_version
{
my $ver = shift;
$ver =~ s/$/000000/;
my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/;
$v = int $v;
$s = int $s;
if ($r < 5 || ($r == 5 && $v < 6)) {
if ($s % 10) {
die "invalid version '$ver'\n";
}
$s /= 10;
$ver = sprintf "%d.%03d", $r, $v;
$s > 0 and $ver .= sprintf "_%02d", $s;
return $ver;
}
return sprintf "%d.%d.%d", $r, $v, $s;
}
sub info
{
$opt{quiet} and return;
print @_, "\n";
}
sub diag
{
$opt{quiet} and return;
$opt{diag} and print @_, "\n";
}
sub warning
{
$opt{quiet} and return;
print "*** ", @_, "\n";
}
sub error
{
print "*** ERROR: ", @_, "\n";
}
my %given_hints;
my %given_warnings;
sub hint
{
$opt{quiet} and return;
my $func = shift;
my $rv = 0;
if (exists $warnings{$func} && !$given_warnings{$func}++) {
my $warn = $warnings{$func};
$warn =~ s!^!*** !mg;
print "*** WARNING: $func\n", $warn;
$rv++;
}
if ($opt{hints} && exists $hints{$func} && !$given_hints{$func}++) {
my $hint = $hints{$func};
$hint =~ s/^/ /mg;
print " --- hint for $func ---\n", $hint;
}
$rv;
}
sub usage
{
my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms;
my %M = ( 'I' => '*' );
$usage =~ s/^\s*perl\s+\S+/$^X $0/;
$usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g;
print < };
my($copy) = $self =~ /^=head\d\s+COPYRIGHT\s*^(.*?)^=\w+/ms;
$copy =~ s/^(?=\S+)/ /gms;
$self =~ s/^$HS+Do NOT edit.*?(?=^-)/$copy/ms;
$self =~ s/^SKIP.*(?=^__DATA__)/SKIP
if (\@ARGV && \$ARGV[0] eq '--unstrip') {
eval { require Devel::PPPort };
\$@ and die "Cannot require Devel::PPPort, please install.\\n";
if (\$Devel::PPPort::VERSION < $VERSION) {
die "$0 was originally generated with Devel::PPPort $VERSION.\\n"
. "Your Devel::PPPort is only version \$Devel::PPPort::VERSION.\\n"
. "Please install a newer version, or --unstrip will not work.\\n";
}
Devel::PPPort::WriteFile(\$0);
exit 0;
}
print <$0" or die "cannot strip $0: $!\n";
print OUT "$pl$c\n";
exit 0;
}
__DATA__
*/
#ifndef _P_P_PORTABILITY_H_
#define _P_P_PORTABILITY_H_
#ifndef DPPP_NAMESPACE
# define DPPP_NAMESPACE DPPP_
#endif
#define DPPP_CAT2(x,y) CAT2(x,y)
#define DPPP_(name) DPPP_CAT2(DPPP_NAMESPACE, name)
#ifndef PERL_REVISION
# if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION))
# define PERL_PATCHLEVEL_H_IMPLICIT
# include
# endif
# if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL)))
# include
# endif
# ifndef PERL_REVISION
# define PERL_REVISION (5)
/* Replace: 1 */
# define PERL_VERSION PATCHLEVEL
# define PERL_SUBVERSION SUBVERSION
/* Replace PERL_PATCHLEVEL with PERL_VERSION */
/* Replace: 0 */
# endif
#endif
#define _dpppDEC2BCD(dec) ((((dec)/100)<<8)|((((dec)%100)/10)<<4)|((dec)%10))
#define PERL_BCDVERSION ((_dpppDEC2BCD(PERL_REVISION)<<24)|(_dpppDEC2BCD(PERL_VERSION)<<12)|_dpppDEC2BCD(PERL_SUBVERSION))
/* It is very unlikely that anyone will try to use this with Perl 6
(or greater), but who knows.
*/
#if PERL_REVISION != 5
# error ppport.h only works with Perl version 5
#endif /* PERL_REVISION != 5 */
#ifdef I_LIMITS
# include
#endif
#ifndef PERL_UCHAR_MIN
# define PERL_UCHAR_MIN ((unsigned char)0)
#endif
#ifndef PERL_UCHAR_MAX
# ifdef UCHAR_MAX
# define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX)
# else
# ifdef MAXUCHAR
# define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR)
# else
# define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0)
# endif
# endif
#endif
#ifndef PERL_USHORT_MIN
# define PERL_USHORT_MIN ((unsigned short)0)
#endif
#ifndef PERL_USHORT_MAX
# ifdef USHORT_MAX
# define PERL_USHORT_MAX ((unsigned short)USHORT_MAX)
# else
# ifdef MAXUSHORT
# define PERL_USHORT_MAX ((unsigned short)MAXUSHORT)
# else
# ifdef USHRT_MAX
# define PERL_USHORT_MAX ((unsigned short)USHRT_MAX)
# else
# define PERL_USHORT_MAX ((unsigned short)~(unsigned)0)
# endif
# endif
# endif
#endif
#ifndef PERL_SHORT_MAX
# ifdef SHORT_MAX
# define PERL_SHORT_MAX ((short)SHORT_MAX)
# else
# ifdef MAXSHORT /* Often used in */
# define PERL_SHORT_MAX ((short)MAXSHORT)
# else
# ifdef SHRT_MAX
# define PERL_SHORT_MAX ((short)SHRT_MAX)
# else
# define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1))
# endif
# endif
# endif
#endif
#ifndef PERL_SHORT_MIN
# ifdef SHORT_MIN
# define PERL_SHORT_MIN ((short)SHORT_MIN)
# else
# ifdef MINSHORT
# define PERL_SHORT_MIN ((short)MINSHORT)
# else
# ifdef SHRT_MIN
# define PERL_SHORT_MIN ((short)SHRT_MIN)
# else
# define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3))
# endif
# endif
# endif
#endif
#ifndef PERL_UINT_MAX
# ifdef UINT_MAX
# define PERL_UINT_MAX ((unsigned int)UINT_MAX)
# else
# ifdef MAXUINT
# define PERL_UINT_MAX ((unsigned int)MAXUINT)
# else
# define PERL_UINT_MAX (~(unsigned int)0)
# endif
# endif
#endif
#ifndef PERL_UINT_MIN
# define PERL_UINT_MIN ((unsigned int)0)
#endif
#ifndef PERL_INT_MAX
# ifdef INT_MAX
# define PERL_INT_MAX ((int)INT_MAX)
# else
# ifdef MAXINT /* Often used in */
# define PERL_INT_MAX ((int)MAXINT)
# else
# define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1))
# endif
# endif
#endif
#ifndef PERL_INT_MIN
# ifdef INT_MIN
# define PERL_INT_MIN ((int)INT_MIN)
# else
# ifdef MININT
# define PERL_INT_MIN ((int)MININT)
# else
# define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3))
# endif
# endif
#endif
#ifndef PERL_ULONG_MAX
# ifdef ULONG_MAX
# define PERL_ULONG_MAX ((unsigned long)ULONG_MAX)
# else
# ifdef MAXULONG
# define PERL_ULONG_MAX ((unsigned long)MAXULONG)
# else
# define PERL_ULONG_MAX (~(unsigned long)0)
# endif
# endif
#endif
#ifndef PERL_ULONG_MIN
# define PERL_ULONG_MIN ((unsigned long)0L)
#endif
#ifndef PERL_LONG_MAX
# ifdef LONG_MAX
# define PERL_LONG_MAX ((long)LONG_MAX)
# else
# ifdef MAXLONG
# define PERL_LONG_MAX ((long)MAXLONG)
# else
# define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1))
# endif
# endif
#endif
#ifndef PERL_LONG_MIN
# ifdef LONG_MIN
# define PERL_LONG_MIN ((long)LONG_MIN)
# else
# ifdef MINLONG
# define PERL_LONG_MIN ((long)MINLONG)
# else
# define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3))
# endif
# endif
#endif
#if defined(HAS_QUAD) && (defined(convex) || defined(uts))
# ifndef PERL_UQUAD_MAX
# ifdef ULONGLONG_MAX
# define PERL_UQUAD_MAX ((unsigned long long)ULONGLONG_MAX)
# else
# ifdef MAXULONGLONG
# define PERL_UQUAD_MAX ((unsigned long long)MAXULONGLONG)
# else
# define PERL_UQUAD_MAX (~(unsigned long long)0)
# endif
# endif
# endif
# ifndef PERL_UQUAD_MIN
# define PERL_UQUAD_MIN ((unsigned long long)0L)
# endif
# ifndef PERL_QUAD_MAX
# ifdef LONGLONG_MAX
# define PERL_QUAD_MAX ((long long)LONGLONG_MAX)
# else
# ifdef MAXLONGLONG
# define PERL_QUAD_MAX ((long long)MAXLONGLONG)
# else
# define PERL_QUAD_MAX ((long long) (PERL_UQUAD_MAX >> 1))
# endif
# endif
# endif
# ifndef PERL_QUAD_MIN
# ifdef LONGLONG_MIN
# define PERL_QUAD_MIN ((long long)LONGLONG_MIN)
# else
# ifdef MINLONGLONG
# define PERL_QUAD_MIN ((long long)MINLONGLONG)
# else
# define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3))
# endif
# endif
# endif
#endif
/* This is based on code from 5.003 perl.h */
#ifdef HAS_QUAD
# ifdef cray
#ifndef IVTYPE
# define IVTYPE int
#endif
#ifndef IV_MIN
# define IV_MIN PERL_INT_MIN
#endif
#ifndef IV_MAX
# define IV_MAX PERL_INT_MAX
#endif
#ifndef UV_MIN
# define UV_MIN PERL_UINT_MIN
#endif
#ifndef UV_MAX
# define UV_MAX PERL_UINT_MAX
#endif
# ifdef INTSIZE
#ifndef IVSIZE
# define IVSIZE INTSIZE
#endif
# endif
# else
# if defined(convex) || defined(uts)
#ifndef IVTYPE
# define IVTYPE long long
#endif
#ifndef IV_MIN
# define IV_MIN PERL_QUAD_MIN
#endif
#ifndef IV_MAX
# define IV_MAX PERL_QUAD_MAX
#endif
#ifndef UV_MIN
# define UV_MIN PERL_UQUAD_MIN
#endif
#ifndef UV_MAX
# define UV_MAX PERL_UQUAD_MAX
#endif
# ifdef LONGLONGSIZE
#ifndef IVSIZE
# define IVSIZE LONGLONGSIZE
#endif
# endif
# else
#ifndef IVTYPE
# define IVTYPE long
#endif
#ifndef IV_MIN
# define IV_MIN PERL_LONG_MIN
#endif
#ifndef IV_MAX
# define IV_MAX PERL_LONG_MAX
#endif
#ifndef UV_MIN
# define UV_MIN PERL_ULONG_MIN
#endif
#ifndef UV_MAX
# define UV_MAX PERL_ULONG_MAX
#endif
# ifdef LONGSIZE
#ifndef IVSIZE
# define IVSIZE LONGSIZE
#endif
# endif
# endif
# endif
#ifndef IVSIZE
# define IVSIZE 8
#endif
#ifndef PERL_QUAD_MIN
# define PERL_QUAD_MIN IV_MIN
#endif
#ifndef PERL_QUAD_MAX
# define PERL_QUAD_MAX IV_MAX
#endif
#ifndef PERL_UQUAD_MIN
# define PERL_UQUAD_MIN UV_MIN
#endif
#ifndef PERL_UQUAD_MAX
# define PERL_UQUAD_MAX UV_MAX
#endif
#else
#ifndef IVTYPE
# define IVTYPE long
#endif
#ifndef IV_MIN
# define IV_MIN PERL_LONG_MIN
#endif
#ifndef IV_MAX
# define IV_MAX PERL_LONG_MAX
#endif
#ifndef UV_MIN
# define UV_MIN PERL_ULONG_MIN
#endif
#ifndef UV_MAX
# define UV_MAX PERL_ULONG_MAX
#endif
#endif
#ifndef IVSIZE
# ifdef LONGSIZE
# define IVSIZE LONGSIZE
# else
# define IVSIZE 4 /* A bold guess, but the best we can make. */
# endif
#endif
#ifndef UVTYPE
# define UVTYPE unsigned IVTYPE
#endif
#ifndef UVSIZE
# define UVSIZE IVSIZE
#endif
#ifndef sv_setuv
# define sv_setuv(sv, uv) \
STMT_START { \
UV TeMpUv = uv; \
if (TeMpUv <= IV_MAX) \
sv_setiv(sv, TeMpUv); \
else \
sv_setnv(sv, (double)TeMpUv); \
} STMT_END
#endif
#ifndef newSVuv
# define newSVuv(uv) ((uv) <= IV_MAX ? newSViv((IV)uv) : newSVnv((NV)uv))
#endif
#ifndef sv_2uv
# define sv_2uv(sv) ((PL_Sv = (sv)), (UV) (SvNOK(PL_Sv) ? SvNV(PL_Sv) : sv_2nv(PL_Sv)))
#endif
#ifndef SvUVX
# define SvUVX(sv) ((UV)SvIVX(sv))
#endif
#ifndef SvUVXx
# define SvUVXx(sv) SvUVX(sv)
#endif
#ifndef SvUV
# define SvUV(sv) (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv))
#endif
#ifndef SvUVx
# define SvUVx(sv) ((PL_Sv = (sv)), SvUV(PL_Sv))
#endif
/* Hint: sv_uv
* Always use the SvUVx() macro instead of sv_uv().
*/
#ifndef sv_uv
# define sv_uv(sv) SvUVx(sv)
#endif
#if !defined(SvUOK) && defined(SvIOK_UV)
# define SvUOK(sv) SvIOK_UV(sv)
#endif
#ifndef XST_mUV
# define XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) )
#endif
#ifndef XSRETURN_UV
# define XSRETURN_UV(v) STMT_START { XST_mUV(0,v); XSRETURN(1); } STMT_END
#endif
#ifndef PUSHu
# define PUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END
#endif
#ifndef XPUSHu
# define XPUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END
#endif
#ifdef HAS_MEMCMP
#ifndef memNE
# define memNE(s1,s2,l) (memcmp(s1,s2,l))
#endif
#ifndef memEQ
# define memEQ(s1,s2,l) (!memcmp(s1,s2,l))
#endif
#else
#ifndef memNE
# define memNE(s1,s2,l) (bcmp(s1,s2,l))
#endif
#ifndef memEQ
# define memEQ(s1,s2,l) (!bcmp(s1,s2,l))
#endif
#endif
#ifndef MoveD
# define MoveD(s,d,n,t) memmove((char*)(d),(char*)(s), (n) * sizeof(t))
#endif
#ifndef CopyD
# define CopyD(s,d,n,t) memcpy((char*)(d),(char*)(s), (n) * sizeof(t))
#endif
#ifdef HAS_MEMSET
#ifndef ZeroD
# define ZeroD(d,n,t) memzero((char*)(d), (n) * sizeof(t))
#endif
#else
#ifndef ZeroD
# define ZeroD(d,n,t) ((void)memzero((char*)(d), (n) * sizeof(t)), d)
#endif
#endif
#ifndef PoisonWith
# define PoisonWith(d,n,t,b) (void)memset((char*)(d), (U8)(b), (n) * sizeof(t))
#endif
#ifndef PoisonNew
# define PoisonNew(d,n,t) PoisonWith(d,n,t,0xAB)
#endif
#ifndef PoisonFree
# define PoisonFree(d,n,t) PoisonWith(d,n,t,0xEF)
#endif
#ifndef Poison
# define Poison(d,n,t) PoisonFree(d,n,t)
#endif
#ifndef Newx
# define Newx(v,n,t) New(0,v,n,t)
#endif
#ifndef Newxc
# define Newxc(v,n,t,c) Newc(0,v,n,t,c)
#endif
#ifndef Newxz
# define Newxz(v,n,t) Newz(0,v,n,t)
#endif
#ifndef PERL_UNUSED_DECL
# ifdef HASATTRIBUTE
# if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER)
# define PERL_UNUSED_DECL
# else
# define PERL_UNUSED_DECL __attribute__((unused))
# endif
# else
# define PERL_UNUSED_DECL
# endif
#endif
#ifndef PERL_UNUSED_ARG
# if defined(lint) && defined(S_SPLINT_S) /* www.splint.org */
# include
# define PERL_UNUSED_ARG(x) NOTE(ARGUNUSED(x))
# else
# define PERL_UNUSED_ARG(x) ((void)x)
# endif
#endif
#ifndef PERL_UNUSED_VAR
# define PERL_UNUSED_VAR(x) ((void)x)
#endif
#ifndef PERL_UNUSED_CONTEXT
# ifdef USE_ITHREADS
# define PERL_UNUSED_CONTEXT PERL_UNUSED_ARG(my_perl)
# else
# define PERL_UNUSED_CONTEXT
# endif
#endif
#ifndef NOOP
# define NOOP /*EMPTY*/(void)0
#endif
#ifndef dNOOP
# define dNOOP extern int /*@unused@*/ Perl___notused PERL_UNUSED_DECL
#endif
#ifndef NVTYPE
# if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE)
# define NVTYPE long double
# else
# define NVTYPE double
# endif
typedef NVTYPE NV;
#endif
#ifndef INT2PTR
# if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE)
# define PTRV UV
# define INT2PTR(any,d) (any)(d)
# else
# if PTRSIZE == LONGSIZE
# define PTRV unsigned long
# else
# define PTRV unsigned
# endif
# define INT2PTR(any,d) (any)(PTRV)(d)
# endif
# define NUM2PTR(any,d) (any)(PTRV)(d)
# define PTR2IV(p) INT2PTR(IV,p)
# define PTR2UV(p) INT2PTR(UV,p)
# define PTR2NV(p) NUM2PTR(NV,p)
# if PTRSIZE == LONGSIZE
# define PTR2ul(p) (unsigned long)(p)
# else
# define PTR2ul(p) INT2PTR(unsigned long,p)
# endif
#endif /* !INT2PTR */
#undef START_EXTERN_C
#undef END_EXTERN_C
#undef EXTERN_C
#ifdef __cplusplus
# define START_EXTERN_C extern "C" {
# define END_EXTERN_C }
# define EXTERN_C extern "C"
#else
# define START_EXTERN_C
# define END_EXTERN_C
# define EXTERN_C extern
#endif
#if defined(PERL_GCC_PEDANTIC)
# ifndef PERL_GCC_BRACE_GROUPS_FORBIDDEN
# define PERL_GCC_BRACE_GROUPS_FORBIDDEN
# endif
#endif
#if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__cplusplus)
# ifndef PERL_USE_GCC_BRACE_GROUPS
# define PERL_USE_GCC_BRACE_GROUPS
# endif
#endif
#undef STMT_START
#undef STMT_END
#ifdef PERL_USE_GCC_BRACE_GROUPS
# define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */
# define STMT_END )
#else
# if defined(VOIDFLAGS) && (VOIDFLAGS) && (defined(sun) || defined(__sun__)) && !defined(__GNUC__)
# define STMT_START if (1)
# define STMT_END else (void)0
# else
# define STMT_START do
# define STMT_END while (0)
# endif
#endif
#ifndef boolSV
# define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no)
#endif
/* DEFSV appears first in 5.004_56 */
#ifndef DEFSV
# define DEFSV GvSV(PL_defgv)
#endif
#ifndef SAVE_DEFSV
# define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv))
#endif
/* Older perls (<=5.003) lack AvFILLp */
#ifndef AvFILLp
# define AvFILLp AvFILL
#endif
#ifndef ERRSV
# define ERRSV get_sv("@",FALSE)
#endif
#ifndef newSVpvn
# define newSVpvn(data,len) ((data) \
? ((len) ? newSVpv((data), (len)) : newSVpv("", 0)) \
: newSV(0))
#endif
/* Hint: gv_stashpvn
* This function's backport doesn't support the length parameter, but
* rather ignores it. Portability can only be ensured if the length
* parameter is used for speed reasons, but the length can always be
* correctly computed from the string argument.
*/
#ifndef gv_stashpvn
# define gv_stashpvn(str,len,create) gv_stashpv(str,create)
#endif
/* Replace: 1 */
#ifndef get_cv
# define get_cv perl_get_cv
#endif
#ifndef get_sv
# define get_sv perl_get_sv
#endif
#ifndef get_av
# define get_av perl_get_av
#endif
#ifndef get_hv
# define get_hv perl_get_hv
#endif
/* Replace: 0 */
#ifndef dUNDERBAR
# define dUNDERBAR dNOOP
#endif
#ifndef UNDERBAR
# define UNDERBAR DEFSV
#endif
#ifndef dAX
# define dAX I32 ax = MARK - PL_stack_base + 1
#endif
#ifndef dITEMS
# define dITEMS I32 items = SP - MARK
#endif
#ifndef dXSTARG
# define dXSTARG SV * targ = sv_newmortal()
#endif
#ifndef dAXMARK
# define dAXMARK I32 ax = POPMARK; \
register SV ** const mark = PL_stack_base + ax++
#endif
#ifndef XSprePUSH
# define XSprePUSH (sp = PL_stack_base + ax - 1)
#endif
#if (PERL_BCDVERSION < 0x5005000)
# undef XSRETURN
# define XSRETURN(off) \
STMT_START { \
PL_stack_sp = PL_stack_base + ax + ((off) - 1); \
return; \
} STMT_END
#endif
#ifndef PERL_ABS
# define PERL_ABS(x) ((x) < 0 ? -(x) : (x))
#endif
#ifndef dVAR
# define dVAR dNOOP
#endif
#ifndef SVf
# define SVf "_"
#endif
#ifndef UTF8_MAXBYTES
# define UTF8_MAXBYTES UTF8_MAXLEN
#endif
#ifndef PERL_HASH
# define PERL_HASH(hash,str,len) \
STMT_START { \
const char *s_PeRlHaSh = str; \
I32 i_PeRlHaSh = len; \
U32 hash_PeRlHaSh = 0; \
while (i_PeRlHaSh--) \
hash_PeRlHaSh = hash_PeRlHaSh * 33 + *s_PeRlHaSh++; \
(hash) = hash_PeRlHaSh; \
} STMT_END
#endif
#ifndef PERL_SIGNALS_UNSAFE_FLAG
#define PERL_SIGNALS_UNSAFE_FLAG 0x0001
#if (PERL_BCDVERSION < 0x5008000)
# define D_PPP_PERL_SIGNALS_INIT PERL_SIGNALS_UNSAFE_FLAG
#else
# define D_PPP_PERL_SIGNALS_INIT 0
#endif
#if defined(NEED_PL_signals)
static U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT;
#elif defined(NEED_PL_signals_GLOBAL)
U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT;
#else
extern U32 DPPP_(my_PL_signals);
#endif
#define PL_signals DPPP_(my_PL_signals)
#endif
/* Hint: PL_ppaddr
* Calling an op via PL_ppaddr requires passing a context argument
* for threaded builds. Since the context argument is different for
* 5.005 perls, you can use aTHXR (supplied by ppport.h), which will
* automatically be defined as the correct argument.
*/
#if (PERL_BCDVERSION <= 0x5005004)
/* Replace: 1 */
# define PL_ppaddr ppaddr
# define PL_no_modify no_modify
/* Replace: 0 */
#endif
#if (PERL_BCDVERSION <= 0x5004005)
/* Replace: 1 */
# define PL_DBsignal DBsignal
# define PL_DBsingle DBsingle
# define PL_DBsub DBsub
# define PL_DBtrace DBtrace
# define PL_Sv Sv
# define PL_compiling compiling
# define PL_copline copline
# define PL_curcop curcop
# define PL_curstash curstash
# define PL_debstash debstash
# define PL_defgv defgv
# define PL_diehook diehook
# define PL_dirty dirty
# define PL_dowarn dowarn
# define PL_errgv errgv
# define PL_expect expect
# define PL_hexdigit hexdigit
# define PL_hints hints
# define PL_laststatval laststatval
# define PL_na na
# define PL_perl_destruct_level perl_destruct_level
# define PL_perldb perldb
# define PL_rsfp_filters rsfp_filters
# define PL_rsfp rsfp
# define PL_stack_base stack_base
# define PL_stack_sp stack_sp
# define PL_statcache statcache
# define PL_stdingv stdingv
# define PL_sv_arenaroot sv_arenaroot
# define PL_sv_no sv_no
# define PL_sv_undef sv_undef
# define PL_sv_yes sv_yes
# define PL_tainted tainted
# define PL_tainting tainting
/* Replace: 0 */
#endif
/* Warning: PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters
* Do not use this variable. It is internal to the perl parser
* and may change or even be removed in the future. Note that
* as of perl 5.9.5 you cannot assign to this variable anymore.
*/
/* TODO: cannot assign to these vars; is it worth fixing? */
#if (PERL_BCDVERSION >= 0x5009005)
# define PL_expect (PL_parser ? PL_parser->expect : 0)
# define PL_copline (PL_parser ? PL_parser->copline : 0)
# define PL_rsfp (PL_parser ? PL_parser->rsfp : (PerlIO *) 0)
# define PL_rsfp_filters (PL_parser ? PL_parser->rsfp_filters : (AV *) 0)
#endif
#ifndef dTHR
# define dTHR dNOOP
#endif
#ifndef dTHX
# define dTHX dNOOP
#endif
#ifndef dTHXa
# define dTHXa(x) dNOOP
#endif
#ifndef pTHX
# define pTHX void
#endif
#ifndef pTHX_
# define pTHX_
#endif
#ifndef aTHX
# define aTHX
#endif
#ifndef aTHX_
# define aTHX_
#endif
#if (PERL_BCDVERSION < 0x5006000)
# ifdef USE_THREADS
# define aTHXR thr
# define aTHXR_ thr,
# else
# define aTHXR
# define aTHXR_
# endif
# define dTHXR dTHR
#else
# define aTHXR aTHX
# define aTHXR_ aTHX_
# define dTHXR dTHX
#endif
#ifndef dTHXoa
# define dTHXoa(x) dTHXa(x)
#endif
#ifndef PUSHmortal
# define PUSHmortal PUSHs(sv_newmortal())
#endif
#ifndef mPUSHp
# define mPUSHp(p,l) sv_setpvn_mg(PUSHmortal, (p), (l))
#endif
#ifndef mPUSHn
# define mPUSHn(n) sv_setnv_mg(PUSHmortal, (NV)(n))
#endif
#ifndef mPUSHi
# define mPUSHi(i) sv_setiv_mg(PUSHmortal, (IV)(i))
#endif
#ifndef mPUSHu
# define mPUSHu(u) sv_setuv_mg(PUSHmortal, (UV)(u))
#endif
#ifndef XPUSHmortal
# define XPUSHmortal XPUSHs(sv_newmortal())
#endif
#ifndef mXPUSHp
# define mXPUSHp(p,l) STMT_START { EXTEND(sp,1); sv_setpvn_mg(PUSHmortal, (p), (l)); } STMT_END
#endif
#ifndef mXPUSHn
# define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv_mg(PUSHmortal, (NV)(n)); } STMT_END
#endif
#ifndef mXPUSHi
# define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv_mg(PUSHmortal, (IV)(i)); } STMT_END
#endif
#ifndef mXPUSHu
# define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv_mg(PUSHmortal, (UV)(u)); } STMT_END
#endif
/* Replace: 1 */
#ifndef call_sv
# define call_sv perl_call_sv
#endif
#ifndef call_pv
# define call_pv perl_call_pv
#endif
#ifndef call_argv
# define call_argv perl_call_argv
#endif
#ifndef call_method
# define call_method perl_call_method
#endif
#ifndef eval_sv
# define eval_sv perl_eval_sv
#endif
#ifndef PERL_LOADMOD_DENY
# define PERL_LOADMOD_DENY 0x1
#endif
#ifndef PERL_LOADMOD_NOIMPORT
# define PERL_LOADMOD_NOIMPORT 0x2
#endif
#ifndef PERL_LOADMOD_IMPORT_OPS
# define PERL_LOADMOD_IMPORT_OPS 0x4
#endif
/* Replace: 0 */
/* Replace perl_eval_pv with eval_pv */
#ifndef eval_pv
#if defined(NEED_eval_pv)
static SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error);
static
#else
extern SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error);
#endif
#ifdef eval_pv
# undef eval_pv
#endif
#define eval_pv(a,b) DPPP_(my_eval_pv)(aTHX_ a,b)
#define Perl_eval_pv DPPP_(my_eval_pv)
#if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL)
SV*
DPPP_(my_eval_pv)(char *p, I32 croak_on_error)
{
dSP;
SV* sv = newSVpv(p, 0);
PUSHMARK(sp);
eval_sv(sv, G_SCALAR);
SvREFCNT_dec(sv);
SPAGAIN;
sv = POPs;
PUTBACK;
if (croak_on_error && SvTRUE(GvSV(errgv)))
croak(SvPVx(GvSV(errgv), na));
return sv;
}
#endif
#endif
#ifndef vload_module
#if defined(NEED_vload_module)
static void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args);
static
#else
extern void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args);
#endif
#ifdef vload_module
# undef vload_module
#endif
#define vload_module(a,b,c,d) DPPP_(my_vload_module)(aTHX_ a,b,c,d)
#define Perl_vload_module DPPP_(my_vload_module)
#if defined(NEED_vload_module) || defined(NEED_vload_module_GLOBAL)
void
DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args)
{
dTHR;
dVAR;
OP *veop, *imop;
OP * const modname = newSVOP(OP_CONST, 0, name);
/* 5.005 has a somewhat hacky force_normal that doesn't croak on
SvREADONLY() if PL_compling is true. Current perls take care in
ck_require() to correctly turn off SvREADONLY before calling
force_normal_flags(). This seems a better fix than fudging PL_compling
*/
SvREADONLY_off(((SVOP*)modname)->op_sv);
modname->op_private |= OPpCONST_BARE;
if (ver) {
veop = newSVOP(OP_CONST, 0, ver);
}
else
veop = NULL;
if (flags & PERL_LOADMOD_NOIMPORT) {
imop = sawparens(newNULLLIST());
}
else if (flags & PERL_LOADMOD_IMPORT_OPS) {
imop = va_arg(*args, OP*);
}
else {
SV *sv;
imop = NULL;
sv = va_arg(*args, SV*);
while (sv) {
imop = append_elem(OP_LIST, imop, newSVOP(OP_CONST, 0, sv));
sv = va_arg(*args, SV*);
}
}
{
const line_t ocopline = PL_copline;
COP * const ocurcop = PL_curcop;
const int oexpect = PL_expect;
#if (PERL_BCDVERSION >= 0x5004000)
utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(FALSE, 0),
veop, modname, imop);
#else
utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(),
modname, imop);
#endif
PL_expect = oexpect;
PL_copline = ocopline;
PL_curcop = ocurcop;
}
}
#endif
#endif
#ifndef load_module
#if defined(NEED_load_module)
static void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...);
static
#else
extern void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...);
#endif
#ifdef load_module
# undef load_module
#endif
#define load_module DPPP_(my_load_module)
#define Perl_load_module DPPP_(my_load_module)
#if defined(NEED_load_module) || defined(NEED_load_module_GLOBAL)
void
DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...)
{
va_list args;
va_start(args, ver);
vload_module(flags, name, ver, &args);
va_end(args);
}
#endif
#endif
#ifndef newRV_inc
# define newRV_inc(sv) newRV(sv) /* Replace */
#endif
#ifndef newRV_noinc
#if defined(NEED_newRV_noinc)
static SV * DPPP_(my_newRV_noinc)(SV *sv);
static
#else
extern SV * DPPP_(my_newRV_noinc)(SV *sv);
#endif
#ifdef newRV_noinc
# undef newRV_noinc
#endif
#define newRV_noinc(a) DPPP_(my_newRV_noinc)(aTHX_ a)
#define Perl_newRV_noinc DPPP_(my_newRV_noinc)
#if defined(NEED_newRV_noinc) || defined(NEED_newRV_noinc_GLOBAL)
SV *
DPPP_(my_newRV_noinc)(SV *sv)
{
SV *rv = (SV *)newRV(sv);
SvREFCNT_dec(sv);
return rv;
}
#endif
#endif
/* Hint: newCONSTSUB
* Returns a CV* as of perl-5.7.1. This return value is not supported
* by Devel::PPPort.
*/
/* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */
#if (PERL_BCDVERSION < 0x5004063) && (PERL_BCDVERSION != 0x5004005)
#if defined(NEED_newCONSTSUB)
static void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv);
static
#else
extern void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv);
#endif
#ifdef newCONSTSUB
# undef newCONSTSUB
#endif
#define newCONSTSUB(a,b,c) DPPP_(my_newCONSTSUB)(aTHX_ a,b,c)
#define Perl_newCONSTSUB DPPP_(my_newCONSTSUB)
#if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL)
void
DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv)
{
U32 oldhints = PL_hints;
HV *old_cop_stash = PL_curcop->cop_stash;
HV *old_curstash = PL_curstash;
line_t oldline = PL_curcop->cop_line;
PL_curcop->cop_line = PL_copline;
PL_hints &= ~HINT_BLOCK_SCOPE;
if (stash)
PL_curstash = PL_curcop->cop_stash = stash;
newSUB(
#if (PERL_BCDVERSION < 0x5003022)
start_subparse(),
#elif (PERL_BCDVERSION == 0x5003022)
start_subparse(0),
#else /* 5.003_23 onwards */
start_subparse(FALSE, 0),
#endif
newSVOP(OP_CONST, 0, newSVpv((char *) name, 0)),
newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */
newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv))
);
PL_hints = oldhints;
PL_curcop->cop_stash = old_cop_stash;
PL_curstash = old_curstash;
PL_curcop->cop_line = oldline;
}
#endif
#endif
/*
* Boilerplate macros for initializing and accessing interpreter-local
* data from C. All statics in extensions should be reworked to use
* this, if you want to make the extension thread-safe. See ext/re/re.xs
* for an example of the use of these macros.
*
* Code that uses these macros is responsible for the following:
* 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts"
* 2. Declare a typedef named my_cxt_t that is a structure that contains
* all the data that needs to be interpreter-local.
* 3. Use the START_MY_CXT macro after the declaration of my_cxt_t.
* 4. Use the MY_CXT_INIT macro such that it is called exactly once
* (typically put in the BOOT: section).
* 5. Use the members of the my_cxt_t structure everywhere as
* MY_CXT.member.
* 6. Use the dMY_CXT macro (a declaration) in all the functions that
* access MY_CXT.
*/
#if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \
defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT)
#ifndef START_MY_CXT
/* This must appear in all extensions that define a my_cxt_t structure,
* right after the definition (i.e. at file scope). The non-threads
* case below uses it to declare the data as static. */
#define START_MY_CXT
#if (PERL_BCDVERSION < 0x5004068)
/* Fetches the SV that keeps the per-interpreter data. */
#define dMY_CXT_SV \
SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE)
#else /* >= perl5.004_68 */
#define dMY_CXT_SV \
SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \
sizeof(MY_CXT_KEY)-1, TRUE)
#endif /* < perl5.004_68 */
/* This declaration should be used within all functions that use the
* interpreter-local data. */
#define dMY_CXT \
dMY_CXT_SV; \
my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv))
/* Creates and zeroes the per-interpreter data.
* (We allocate my_cxtp in a Perl SV so that it will be released when
* the interpreter goes away.) */
#define MY_CXT_INIT \
dMY_CXT_SV; \
/* newSV() allocates one more than needed */ \
my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
Zero(my_cxtp, 1, my_cxt_t); \
sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
/* This macro must be used to access members of the my_cxt_t structure.
* e.g. MYCXT.some_data */
#define MY_CXT (*my_cxtp)
/* Judicious use of these macros can reduce the number of times dMY_CXT
* is used. Use is similar to pTHX, aTHX etc. */
#define pMY_CXT my_cxt_t *my_cxtp
#define pMY_CXT_ pMY_CXT,
#define _pMY_CXT ,pMY_CXT
#define aMY_CXT my_cxtp
#define aMY_CXT_ aMY_CXT,
#define _aMY_CXT ,aMY_CXT
#endif /* START_MY_CXT */
#ifndef MY_CXT_CLONE
/* Clones the per-interpreter data. */
#define MY_CXT_CLONE \
dMY_CXT_SV; \
my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\
Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t);\
sv_setuv(my_cxt_sv, PTR2UV(my_cxtp))
#endif
#else /* single interpreter */
#ifndef START_MY_CXT
#define START_MY_CXT static my_cxt_t my_cxt;
#define dMY_CXT_SV dNOOP
#define dMY_CXT dNOOP
#define MY_CXT_INIT NOOP
#define MY_CXT my_cxt
#define pMY_CXT void
#define pMY_CXT_
#define _pMY_CXT
#define aMY_CXT
#define aMY_CXT_
#define _aMY_CXT
#endif /* START_MY_CXT */
#ifndef MY_CXT_CLONE
#define MY_CXT_CLONE NOOP
#endif
#endif
#ifndef IVdf
# if IVSIZE == LONGSIZE
# define IVdf "ld"
# define UVuf "lu"
# define UVof "lo"
# define UVxf "lx"
# define UVXf "lX"
# else
# if IVSIZE == INTSIZE
# define IVdf "d"
# define UVuf "u"
# define UVof "o"
# define UVxf "x"
# define UVXf "X"
# endif
# endif
#endif
#ifndef NVef
# if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \
defined(PERL_PRIfldbl) /* Not very likely, but let's try anyway. */
# define NVef PERL_PRIeldbl
# define NVff PERL_PRIfldbl
# define NVgf PERL_PRIgldbl
# else
# define NVef "e"
# define NVff "f"
# define NVgf "g"
# endif
#endif
#ifndef SvREFCNT_inc
# ifdef PERL_USE_GCC_BRACE_GROUPS
# define SvREFCNT_inc(sv) \
({ \
SV * const _sv = (SV*)(sv); \
if (_sv) \
(SvREFCNT(_sv))++; \
_sv; \
})
# else
# define SvREFCNT_inc(sv) \
((PL_Sv=(SV*)(sv)) ? (++(SvREFCNT(PL_Sv)),PL_Sv) : NULL)
# endif
#endif
#ifndef SvREFCNT_inc_simple
# ifdef PERL_USE_GCC_BRACE_GROUPS
# define SvREFCNT_inc_simple(sv) \
({ \
if (sv) \
(SvREFCNT(sv))++; \
(SV *)(sv); \
})
# else
# define SvREFCNT_inc_simple(sv) \
((sv) ? (SvREFCNT(sv)++,(SV*)(sv)) : NULL)
# endif
#endif
#ifndef SvREFCNT_inc_NN
# ifdef PERL_USE_GCC_BRACE_GROUPS
# define SvREFCNT_inc_NN(sv) \
({ \
SV * const _sv = (SV*)(sv); \
SvREFCNT(_sv)++; \
_sv; \
})
# else
# define SvREFCNT_inc_NN(sv) \
(PL_Sv=(SV*)(sv),++(SvREFCNT(PL_Sv)),PL_Sv)
# endif
#endif
#ifndef SvREFCNT_inc_void
# ifdef PERL_USE_GCC_BRACE_GROUPS
# define SvREFCNT_inc_void(sv) \
({ \
SV * const _sv = (SV*)(sv); \
if (_sv) \
(void)(SvREFCNT(_sv)++); \
})
# else
# define SvREFCNT_inc_void(sv) \
(void)((PL_Sv=(SV*)(sv)) ? ++(SvREFCNT(PL_Sv)) : 0)
# endif
#endif
#ifndef SvREFCNT_inc_simple_void
# define SvREFCNT_inc_simple_void(sv) STMT_START { if (sv) SvREFCNT(sv)++; } STMT_END
#endif
#ifndef SvREFCNT_inc_simple_NN
# define SvREFCNT_inc_simple_NN(sv) (++SvREFCNT(sv), (SV*)(sv))
#endif
#ifndef SvREFCNT_inc_void_NN
# define SvREFCNT_inc_void_NN(sv) (void)(++SvREFCNT((SV*)(sv)))
#endif
#ifndef SvREFCNT_inc_simple_void_NN
# define SvREFCNT_inc_simple_void_NN(sv) (void)(++SvREFCNT((SV*)(sv)))
#endif
/* Backwards compatibility stuff... :-( */
#if !defined(NEED_sv_2pv_flags) && defined(NEED_sv_2pv_nolen)
# define NEED_sv_2pv_flags
#endif
#if !defined(NEED_sv_2pv_flags_GLOBAL) && defined(NEED_sv_2pv_nolen_GLOBAL)
# define NEED_sv_2pv_flags_GLOBAL
#endif
/* Hint: sv_2pv_nolen
* Use the SvPV_nolen() or SvPV_nolen_const() macros instead of sv_2pv_nolen().
*/
#ifndef sv_2pv_nolen
# define sv_2pv_nolen(sv) SvPV_nolen(sv)
#endif
#ifdef SvPVbyte
/* Hint: SvPVbyte
* Does not work in perl-5.6.1, ppport.h implements a version
* borrowed from perl-5.7.3.
*/
#if (PERL_BCDVERSION < 0x5007000)
#if defined(NEED_sv_2pvbyte)
static char * DPPP_(my_sv_2pvbyte)(pTHX_ SV * sv, STRLEN * lp);
static
#else
extern char * DPPP_(my_sv_2pvbyte)(pTHX_ SV * sv, STRLEN * lp);
#endif
#ifdef sv_2pvbyte
# undef sv_2pvbyte
#endif
#define sv_2pvbyte(a,b) DPPP_(my_sv_2pvbyte)(aTHX_ a,b)
#define Perl_sv_2pvbyte DPPP_(my_sv_2pvbyte)
#if defined(NEED_sv_2pvbyte) || defined(NEED_sv_2pvbyte_GLOBAL)
char *
DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp)
{
sv_utf8_downgrade(sv,0);
return SvPV(sv,*lp);
}
#endif
/* Hint: sv_2pvbyte
* Use the SvPVbyte() macro instead of sv_2pvbyte().
*/
#undef SvPVbyte
#define SvPVbyte(sv, lp) \
((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \
? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp))
#endif
#else
# define SvPVbyte SvPV
# define sv_2pvbyte sv_2pv
#endif
#ifndef sv_2pvbyte_nolen
# define sv_2pvbyte_nolen(sv) sv_2pv_nolen(sv)
#endif
/* Hint: sv_pvn
* Always use the SvPV() macro instead of sv_pvn().
*/
/* Hint: sv_pvn_force
* Always use the SvPV_force() macro instead of sv_pvn_force().
*/
/* If these are undefined, they're not handled by the core anyway */
#ifndef SV_IMMEDIATE_UNREF
# define SV_IMMEDIATE_UNREF 0
#endif
#ifndef SV_GMAGIC
# define SV_GMAGIC 0
#endif
#ifndef SV_COW_DROP_PV
# define SV_COW_DROP_PV 0
#endif
#ifndef SV_UTF8_NO_ENCODING
# define SV_UTF8_NO_ENCODING 0
#endif
#ifndef SV_NOSTEAL
# define SV_NOSTEAL 0
#endif
#ifndef SV_CONST_RETURN
# define SV_CONST_RETURN 0
#endif
#ifndef SV_MUTABLE_RETURN
# define SV_MUTABLE_RETURN 0
#endif
#ifndef SV_SMAGIC
# define SV_SMAGIC 0
#endif
#ifndef SV_HAS_TRAILING_NUL
# define SV_HAS_TRAILING_NUL 0
#endif
#ifndef SV_COW_SHARED_HASH_KEYS
# define SV_COW_SHARED_HASH_KEYS 0
#endif
#if (PERL_BCDVERSION < 0x5007002)
#if defined(NEED_sv_2pv_flags)
static char * DPPP_(my_sv_2pv_flags)(pTHX_ SV * sv, STRLEN * lp, I32 flags);
static
#else
extern char * DPPP_(my_sv_2pv_flags)(pTHX_ SV * sv, STRLEN * lp, I32 flags);
#endif
#ifdef sv_2pv_flags
# undef sv_2pv_flags
#endif
#define sv_2pv_flags(a,b,c) DPPP_(my_sv_2pv_flags)(aTHX_ a,b,c)
#define Perl_sv_2pv_flags DPPP_(my_sv_2pv_flags)
#if defined(NEED_sv_2pv_flags) || defined(NEED_sv_2pv_flags_GLOBAL)
char *
DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags)
{
STRLEN n_a = (STRLEN) flags;
return sv_2pv(sv, lp ? lp : &n_a);
}
#endif
#if defined(NEED_sv_pvn_force_flags)
static char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV * sv, STRLEN * lp, I32 flags);
static
#else
extern char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV * sv, STRLEN * lp, I32 flags);
#endif
#ifdef sv_pvn_force_flags
# undef sv_pvn_force_flags
#endif
#define sv_pvn_force_flags(a,b,c) DPPP_(my_sv_pvn_force_flags)(aTHX_ a,b,c)
#define Perl_sv_pvn_force_flags DPPP_(my_sv_pvn_force_flags)
#if defined(NEED_sv_pvn_force_flags) || defined(NEED_sv_pvn_force_flags_GLOBAL)
char *
DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags)
{
STRLEN n_a = (STRLEN) flags;
return sv_pvn_force(sv, lp ? lp : &n_a);
}
#endif
#endif
#ifndef SvPV_const
# define SvPV_const(sv, lp) SvPV_flags_const(sv, lp, SV_GMAGIC)
#endif
#ifndef SvPV_mutable
# define SvPV_mutable(sv, lp) SvPV_flags_mutable(sv, lp, SV_GMAGIC)
#endif
#ifndef SvPV_flags
# define SvPV_flags(sv, lp, flags) \
((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pv_flags(sv, &lp, flags))
#endif
#ifndef SvPV_flags_const
# define SvPV_flags_const(sv, lp, flags) \
((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
? ((lp = SvCUR(sv)), SvPVX_const(sv)) : \
(const char*) sv_2pv_flags(sv, &lp, flags|SV_CONST_RETURN))
#endif
#ifndef SvPV_flags_const_nolen
# define SvPV_flags_const_nolen(sv, flags) \
((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
? SvPVX_const(sv) : \
(const char*) sv_2pv_flags(sv, 0, flags|SV_CONST_RETURN))
#endif
#ifndef SvPV_flags_mutable
# define SvPV_flags_mutable(sv, lp, flags) \
((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) : \
sv_2pv_flags(sv, &lp, flags|SV_MUTABLE_RETURN))
#endif
#ifndef SvPV_force
# define SvPV_force(sv, lp) SvPV_force_flags(sv, lp, SV_GMAGIC)
#endif
#ifndef SvPV_force_nolen
# define SvPV_force_nolen(sv) SvPV_force_flags_nolen(sv, SV_GMAGIC)
#endif
#ifndef SvPV_force_mutable
# define SvPV_force_mutable(sv, lp) SvPV_force_flags_mutable(sv, lp, SV_GMAGIC)
#endif
#ifndef SvPV_force_nomg
# define SvPV_force_nomg(sv, lp) SvPV_force_flags(sv, lp, 0)
#endif
#ifndef SvPV_force_nomg_nolen
# define SvPV_force_nomg_nolen(sv) SvPV_force_flags_nolen(sv, 0)
#endif
#ifndef SvPV_force_flags
# define SvPV_force_flags(sv, lp, flags) \
((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \
? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_pvn_force_flags(sv, &lp, flags))
#endif
#ifndef SvPV_force_flags_nolen
# define SvPV_force_flags_nolen(sv, flags) \
((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \
? SvPVX(sv) : sv_pvn_force_flags(sv, 0, flags))
#endif
#ifndef SvPV_force_flags_mutable
# define SvPV_force_flags_mutable(sv, lp, flags) \
((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \
? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) \
: sv_pvn_force_flags(sv, &lp, flags|SV_MUTABLE_RETURN))
#endif
#ifndef SvPV_nolen
# define SvPV_nolen(sv) \
((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
? SvPVX(sv) : sv_2pv_flags(sv, 0, SV_GMAGIC))
#endif
#ifndef SvPV_nolen_const
# define SvPV_nolen_const(sv) \
((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \
? SvPVX_const(sv) : sv_2pv_flags(sv, 0, SV_GMAGIC|SV_CONST_RETURN))
#endif
#ifndef SvPV_nomg
# define SvPV_nomg(sv, lp) SvPV_flags(sv, lp, 0)
#endif
#ifndef SvPV_nomg_const
# define SvPV_nomg_const(sv, lp) SvPV_flags_const(sv, lp, 0)
#endif
#ifndef SvPV_nomg_const_nolen
# define SvPV_nomg_const_nolen(sv) SvPV_flags_const_nolen(sv, 0)
#endif
#ifndef SvMAGIC_set
# define SvMAGIC_set(sv, val) \
STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \
(((XPVMG*) SvANY(sv))->xmg_magic = (val)); } STMT_END
#endif
#if (PERL_BCDVERSION < 0x5009003)
#ifndef SvPVX_const
# define SvPVX_const(sv) ((const char*) (0 + SvPVX(sv)))
#endif
#ifndef SvPVX_mutable
# define SvPVX_mutable(sv) (0 + SvPVX(sv))
#endif
#ifndef SvRV_set
# define SvRV_set(sv, val) \
STMT_START { assert(SvTYPE(sv) >= SVt_RV); \
(((XRV*) SvANY(sv))->xrv_rv = (val)); } STMT_END
#endif
#else
#ifndef SvPVX_const
# define SvPVX_const(sv) ((const char*)((sv)->sv_u.svu_pv))
#endif
#ifndef SvPVX_mutable
# define SvPVX_mutable(sv) ((sv)->sv_u.svu_pv)
#endif
#ifndef SvRV_set
# define SvRV_set(sv, val) \
STMT_START { assert(SvTYPE(sv) >= SVt_RV); \
((sv)->sv_u.svu_rv = (val)); } STMT_END
#endif
#endif
#ifndef SvSTASH_set
# define SvSTASH_set(sv, val) \
STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \
(((XPVMG*) SvANY(sv))->xmg_stash = (val)); } STMT_END
#endif
#if (PERL_BCDVERSION < 0x5004000)
#ifndef SvUV_set
# define SvUV_set(sv, val) \
STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \
(((XPVIV*) SvANY(sv))->xiv_iv = (IV) (val)); } STMT_END
#endif
#else
#ifndef SvUV_set
# define SvUV_set(sv, val) \
STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \
(((XPVUV*) SvANY(sv))->xuv_uv = (val)); } STMT_END
#endif
#endif
#if (PERL_BCDVERSION >= 0x5004000) && !defined(vnewSVpvf)
#if defined(NEED_vnewSVpvf)
static SV * DPPP_(my_vnewSVpvf)(pTHX_ const char * pat, va_list * args);
static
#else
extern SV * DPPP_(my_vnewSVpvf)(pTHX_ const char * pat, va_list * args);
#endif
#ifdef vnewSVpvf
# undef vnewSVpvf
#endif
#define vnewSVpvf(a,b) DPPP_(my_vnewSVpvf)(aTHX_ a,b)
#define Perl_vnewSVpvf DPPP_(my_vnewSVpvf)
#if defined(NEED_vnewSVpvf) || defined(NEED_vnewSVpvf_GLOBAL)
SV *
DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args)
{
register SV *sv = newSV(0);
sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*));
return sv;
}
#endif
#endif
#if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf)
# define sv_vcatpvf(sv, pat, args) sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*))
#endif
#if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf)
# define sv_vsetpvf(sv, pat, args) sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*))
#endif
#if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg)
#if defined(NEED_sv_catpvf_mg)
static void DPPP_(my_sv_catpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
static
#else
extern void DPPP_(my_sv_catpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
#endif
#define Perl_sv_catpvf_mg DPPP_(my_sv_catpvf_mg)
#if defined(NEED_sv_catpvf_mg) || defined(NEED_sv_catpvf_mg_GLOBAL)
void
DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...)
{
va_list args;
va_start(args, pat);
sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
SvSETMAGIC(sv);
va_end(args);
}
#endif
#endif
#ifdef PERL_IMPLICIT_CONTEXT
#if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg_nocontext)
#if defined(NEED_sv_catpvf_mg_nocontext)
static void DPPP_(my_sv_catpvf_mg_nocontext)(SV * sv, const char * pat, ...);
static
#else
extern void DPPP_(my_sv_catpvf_mg_nocontext)(SV * sv, const char * pat, ...);
#endif
#define sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext)
#define Perl_sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext)
#if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL)
void
DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...)
{
dTHX;
va_list args;
va_start(args, pat);
sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
SvSETMAGIC(sv);
va_end(args);
}
#endif
#endif
#endif
/* sv_catpvf_mg depends on sv_catpvf_mg_nocontext */
#ifndef sv_catpvf_mg
# ifdef PERL_IMPLICIT_CONTEXT
# define sv_catpvf_mg Perl_sv_catpvf_mg_nocontext
# else
# define sv_catpvf_mg Perl_sv_catpvf_mg
# endif
#endif
#if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf_mg)
# define sv_vcatpvf_mg(sv, pat, args) \
STMT_START { \
sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \
SvSETMAGIC(sv); \
} STMT_END
#endif
#if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg)
#if defined(NEED_sv_setpvf_mg)
static void DPPP_(my_sv_setpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
static
#else
extern void DPPP_(my_sv_setpvf_mg)(pTHX_ SV * sv, const char * pat, ...);
#endif
#define Perl_sv_setpvf_mg DPPP_(my_sv_setpvf_mg)
#if defined(NEED_sv_setpvf_mg) || defined(NEED_sv_setpvf_mg_GLOBAL)
void
DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...)
{
va_list args;
va_start(args, pat);
sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
SvSETMAGIC(sv);
va_end(args);
}
#endif
#endif
#ifdef PERL_IMPLICIT_CONTEXT
#if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg_nocontext)
#if defined(NEED_sv_setpvf_mg_nocontext)
static void DPPP_(my_sv_setpvf_mg_nocontext)(SV * sv, const char * pat, ...);
static
#else
extern void DPPP_(my_sv_setpvf_mg_nocontext)(SV * sv, const char * pat, ...);
#endif
#define sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext)
#define Perl_sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext)
#if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL)
void
DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...)
{
dTHX;
va_list args;
va_start(args, pat);
sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
SvSETMAGIC(sv);
va_end(args);
}
#endif
#endif
#endif
/* sv_setpvf_mg depends on sv_setpvf_mg_nocontext */
#ifndef sv_setpvf_mg
# ifdef PERL_IMPLICIT_CONTEXT
# define sv_setpvf_mg Perl_sv_setpvf_mg_nocontext
# else
# define sv_setpvf_mg Perl_sv_setpvf_mg
# endif
#endif
#if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf_mg)
# define sv_vsetpvf_mg(sv, pat, args) \
STMT_START { \
sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \
SvSETMAGIC(sv); \
} STMT_END
#endif
#ifndef newSVpvn_share
#if defined(NEED_newSVpvn_share)
static SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash);
static
#else
extern SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash);
#endif
#ifdef newSVpvn_share
# undef newSVpvn_share
#endif
#define newSVpvn_share(a,b,c) DPPP_(my_newSVpvn_share)(aTHX_ a,b,c)
#define Perl_newSVpvn_share DPPP_(my_newSVpvn_share)
#if defined(NEED_newSVpvn_share) || defined(NEED_newSVpvn_share_GLOBAL)
SV *
DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash)
{
SV *sv;
if (len < 0)
len = -len;
if (!hash)
PERL_HASH(hash, (char*) src, len);
sv = newSVpvn((char *) src, len);
sv_upgrade(sv, SVt_PVIV);
SvIVX(sv) = hash;
SvREADONLY_on(sv);
SvPOK_on(sv);
return sv;
}
#endif
#endif
#ifndef SvSHARED_HASH
# define SvSHARED_HASH(sv) (0 + SvUVX(sv))
#endif
#ifndef WARN_ALL
# define WARN_ALL 0
#endif
#ifndef WARN_CLOSURE
# define WARN_CLOSURE 1
#endif
#ifndef WARN_DEPRECATED
# define WARN_DEPRECATED 2
#endif
#ifndef WARN_EXITING
# define WARN_EXITING 3
#endif
#ifndef WARN_GLOB
# define WARN_GLOB 4
#endif
#ifndef WARN_IO
# define WARN_IO 5
#endif
#ifndef WARN_CLOSED
# define WARN_CLOSED 6
#endif
#ifndef WARN_EXEC
# define WARN_EXEC 7
#endif
#ifndef WARN_LAYER
# define WARN_LAYER 8
#endif
#ifndef WARN_NEWLINE
# define WARN_NEWLINE 9
#endif
#ifndef WARN_PIPE
# define WARN_PIPE 10
#endif
#ifndef WARN_UNOPENED
# define WARN_UNOPENED 11
#endif
#ifndef WARN_MISC
# define WARN_MISC 12
#endif
#ifndef WARN_NUMERIC
# define WARN_NUMERIC 13
#endif
#ifndef WARN_ONCE
# define WARN_ONCE 14
#endif
#ifndef WARN_OVERFLOW
# define WARN_OVERFLOW 15
#endif
#ifndef WARN_PACK
# define WARN_PACK 16
#endif
#ifndef WARN_PORTABLE
# define WARN_PORTABLE 17
#endif
#ifndef WARN_RECURSION
# define WARN_RECURSION 18
#endif
#ifndef WARN_REDEFINE
# define WARN_REDEFINE 19
#endif
#ifndef WARN_REGEXP
# define WARN_REGEXP 20
#endif
#ifndef WARN_SEVERE
# define WARN_SEVERE 21
#endif
#ifndef WARN_DEBUGGING
# define WARN_DEBUGGING 22
#endif
#ifndef WARN_INPLACE
# define WARN_INPLACE 23
#endif
#ifndef WARN_INTERNAL
# define WARN_INTERNAL 24
#endif
#ifndef WARN_MALLOC
# define WARN_MALLOC 25
#endif
#ifndef WARN_SIGNAL
# define WARN_SIGNAL 26
#endif
#ifndef WARN_SUBSTR
# define WARN_SUBSTR 27
#endif
#ifndef WARN_SYNTAX
# define WARN_SYNTAX 28
#endif
#ifndef WARN_AMBIGUOUS
# define WARN_AMBIGUOUS 29
#endif
#ifndef WARN_BAREWORD
# define WARN_BAREWORD 30
#endif
#ifndef WARN_DIGIT
# define WARN_DIGIT 31
#endif
#ifndef WARN_PARENTHESIS
# define WARN_PARENTHESIS 32
#endif
#ifndef WARN_PRECEDENCE
# define WARN_PRECEDENCE 33
#endif
#ifndef WARN_PRINTF
# define WARN_PRINTF 34
#endif
#ifndef WARN_PROTOTYPE
# define WARN_PROTOTYPE 35
#endif
#ifndef WARN_QW
# define WARN_QW 36
#endif
#ifndef WARN_RESERVED
# define WARN_RESERVED 37
#endif
#ifndef WARN_SEMICOLON
# define WARN_SEMICOLON 38
#endif
#ifndef WARN_TAINT
# define WARN_TAINT 39
#endif
#ifndef WARN_THREADS
# define WARN_THREADS 40
#endif
#ifndef WARN_UNINITIALIZED
# define WARN_UNINITIALIZED 41
#endif
#ifndef WARN_UNPACK
# define WARN_UNPACK 42
#endif
#ifndef WARN_UNTIE
# define WARN_UNTIE 43
#endif
#ifndef WARN_UTF8
# define WARN_UTF8 44
#endif
#ifndef WARN_VOID
# define WARN_VOID 45
#endif
#ifndef WARN_ASSERTIONS
# define WARN_ASSERTIONS 46
#endif
#ifndef packWARN
# define packWARN(a) (a)
#endif
#ifndef ckWARN
# ifdef G_WARN_ON
# define ckWARN(a) (PL_dowarn & G_WARN_ON)
# else
# define ckWARN(a) PL_dowarn
# endif
#endif
#if (PERL_BCDVERSION >= 0x5004000) && !defined(warner)
#if defined(NEED_warner)
static void DPPP_(my_warner)(U32 err, const char *pat, ...);
static
#else
extern void DPPP_(my_warner)(U32 err, const char *pat, ...);
#endif
#define Perl_warner DPPP_(my_warner)
#if defined(NEED_warner) || defined(NEED_warner_GLOBAL)
void
DPPP_(my_warner)(U32 err, const char *pat, ...)
{
SV *sv;
va_list args;
PERL_UNUSED_ARG(err);
va_start(args, pat);
sv = vnewSVpvf(pat, &args);
va_end(args);
sv_2mortal(sv);
warn("%s", SvPV_nolen(sv));
}
#define warner Perl_warner
#define Perl_warner_nocontext Perl_warner
#endif
#endif
/* concatenating with "" ensures that only literal strings are accepted as argument
* note that STR_WITH_LEN() can't be used as argument to macros or functions that
* under some configurations might be macros
*/
#ifndef STR_WITH_LEN
# define STR_WITH_LEN(s) (s ""), (sizeof(s)-1)
#endif
#ifndef newSVpvs
# define newSVpvs(str) newSVpvn(str "", sizeof(str) - 1)
#endif
#ifndef sv_catpvs
# define sv_catpvs(sv, str) sv_catpvn(sv, str "", sizeof(str) - 1)
#endif
#ifndef sv_setpvs
# define sv_setpvs(sv, str) sv_setpvn(sv, str "", sizeof(str) - 1)
#endif
#ifndef hv_fetchs
# define hv_fetchs(hv, key, lval) hv_fetch(hv, key "", sizeof(key) - 1, lval)
#endif
#ifndef hv_stores
# define hv_stores(hv, key, val) hv_store(hv, key "", sizeof(key) - 1, val, 0)
#endif
#ifndef SvGETMAGIC
# define SvGETMAGIC(x) STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END
#endif
#ifndef PERL_MAGIC_sv
# define PERL_MAGIC_sv '\0'
#endif
#ifndef PERL_MAGIC_overload
# define PERL_MAGIC_overload 'A'
#endif
#ifndef PERL_MAGIC_overload_elem
# define PERL_MAGIC_overload_elem 'a'
#endif
#ifndef PERL_MAGIC_overload_table
# define PERL_MAGIC_overload_table 'c'
#endif
#ifndef PERL_MAGIC_bm
# define PERL_MAGIC_bm 'B'
#endif
#ifndef PERL_MAGIC_regdata
# define PERL_MAGIC_regdata 'D'
#endif
#ifndef PERL_MAGIC_regdatum
# define PERL_MAGIC_regdatum 'd'
#endif
#ifndef PERL_MAGIC_env
# define PERL_MAGIC_env 'E'
#endif
#ifndef PERL_MAGIC_envelem
# define PERL_MAGIC_envelem 'e'
#endif
#ifndef PERL_MAGIC_fm
# define PERL_MAGIC_fm 'f'
#endif
#ifndef PERL_MAGIC_regex_global
# define PERL_MAGIC_regex_global 'g'
#endif
#ifndef PERL_MAGIC_isa
# define PERL_MAGIC_isa 'I'
#endif
#ifndef PERL_MAGIC_isaelem
# define PERL_MAGIC_isaelem 'i'
#endif
#ifndef PERL_MAGIC_nkeys
# define PERL_MAGIC_nkeys 'k'
#endif
#ifndef PERL_MAGIC_dbfile
# define PERL_MAGIC_dbfile 'L'
#endif
#ifndef PERL_MAGIC_dbline
# define PERL_MAGIC_dbline 'l'
#endif
#ifndef PERL_MAGIC_mutex
# define PERL_MAGIC_mutex 'm'
#endif
#ifndef PERL_MAGIC_shared
# define PERL_MAGIC_shared 'N'
#endif
#ifndef PERL_MAGIC_shared_scalar
# define PERL_MAGIC_shared_scalar 'n'
#endif
#ifndef PERL_MAGIC_collxfrm
# define PERL_MAGIC_collxfrm 'o'
#endif
#ifndef PERL_MAGIC_tied
# define PERL_MAGIC_tied 'P'
#endif
#ifndef PERL_MAGIC_tiedelem
# define PERL_MAGIC_tiedelem 'p'
#endif
#ifndef PERL_MAGIC_tiedscalar
# define PERL_MAGIC_tiedscalar 'q'
#endif
#ifndef PERL_MAGIC_qr
# define PERL_MAGIC_qr 'r'
#endif
#ifndef PERL_MAGIC_sig
# define PERL_MAGIC_sig 'S'
#endif
#ifndef PERL_MAGIC_sigelem
# define PERL_MAGIC_sigelem 's'
#endif
#ifndef PERL_MAGIC_taint
# define PERL_MAGIC_taint 't'
#endif
#ifndef PERL_MAGIC_uvar
# define PERL_MAGIC_uvar 'U'
#endif
#ifndef PERL_MAGIC_uvar_elem
# define PERL_MAGIC_uvar_elem 'u'
#endif
#ifndef PERL_MAGIC_vstring
# define PERL_MAGIC_vstring 'V'
#endif
#ifndef PERL_MAGIC_vec
# define PERL_MAGIC_vec 'v'
#endif
#ifndef PERL_MAGIC_utf8
# define PERL_MAGIC_utf8 'w'
#endif
#ifndef PERL_MAGIC_substr
# define PERL_MAGIC_substr 'x'
#endif
#ifndef PERL_MAGIC_defelem
# define PERL_MAGIC_defelem 'y'
#endif
#ifndef PERL_MAGIC_glob
# define PERL_MAGIC_glob '*'
#endif
#ifndef PERL_MAGIC_arylen
# define PERL_MAGIC_arylen '#'
#endif
#ifndef PERL_MAGIC_pos
# define PERL_MAGIC_pos '.'
#endif
#ifndef PERL_MAGIC_backref
# define PERL_MAGIC_backref '<'
#endif
#ifndef PERL_MAGIC_ext
# define PERL_MAGIC_ext '~'
#endif
/* That's the best we can do... */
#ifndef sv_catpvn_nomg
# define sv_catpvn_nomg sv_catpvn
#endif
#ifndef sv_catsv_nomg
# define sv_catsv_nomg sv_catsv
#endif
#ifndef sv_setsv_nomg
# define sv_setsv_nomg sv_setsv
#endif
#ifndef sv_pvn_nomg
# define sv_pvn_nomg sv_pvn
#endif
#ifndef SvIV_nomg
# define SvIV_nomg SvIV
#endif
#ifndef SvUV_nomg
# define SvUV_nomg SvUV
#endif
#ifndef sv_catpv_mg
# define sv_catpv_mg(sv, ptr) \
STMT_START { \
SV *TeMpSv = sv; \
sv_catpv(TeMpSv,ptr); \
SvSETMAGIC(TeMpSv); \
} STMT_END
#endif
#ifndef sv_catpvn_mg
# define sv_catpvn_mg(sv, ptr, len) \
STMT_START { \
SV *TeMpSv = sv; \
sv_catpvn(TeMpSv,ptr,len); \
SvSETMAGIC(TeMpSv); \
} STMT_END
#endif
#ifndef sv_catsv_mg
# define sv_catsv_mg(dsv, ssv) \
STMT_START { \
SV *TeMpSv = dsv; \
sv_catsv(TeMpSv,ssv); \
SvSETMAGIC(TeMpSv); \
} STMT_END
#endif
#ifndef sv_setiv_mg
# define sv_setiv_mg(sv, i) \
STMT_START { \
SV *TeMpSv = sv; \
sv_setiv(TeMpSv,i); \
SvSETMAGIC(TeMpSv); \
} STMT_END
#endif
#ifndef sv_setnv_mg
# define sv_setnv_mg(sv, num) \
STMT_START { \
SV *TeMpSv = sv; \
sv_setnv(TeMpSv,num); \
SvSETMAGIC(TeMpSv); \
} STMT_END
#endif
#ifndef sv_setpv_mg
# define sv_setpv_mg(sv, ptr) \
STMT_START { \
SV *TeMpSv = sv; \
sv_setpv(TeMpSv,ptr); \
SvSETMAGIC(TeMpSv); \
} STMT_END
#endif
#ifndef sv_setpvn_mg
# define sv_setpvn_mg(sv, ptr, len) \
STMT_START { \
SV *TeMpSv = sv; \
sv_setpvn(TeMpSv,ptr,len); \
SvSETMAGIC(TeMpSv); \
} STMT_END
#endif
#ifndef sv_setsv_mg
# define sv_setsv_mg(dsv, ssv) \
STMT_START { \
SV *TeMpSv = dsv; \
sv_setsv(TeMpSv,ssv); \
SvSETMAGIC(TeMpSv); \
} STMT_END
#endif
#ifndef sv_setuv_mg
# define sv_setuv_mg(sv, i) \
STMT_START { \
SV *TeMpSv = sv; \
sv_setuv(TeMpSv,i); \
SvSETMAGIC(TeMpSv); \
} STMT_END
#endif
#ifndef sv_usepvn_mg
# define sv_usepvn_mg(sv, ptr, len) \
STMT_START { \
SV *TeMpSv = sv; \
sv_usepvn(TeMpSv,ptr,len); \
SvSETMAGIC(TeMpSv); \
} STMT_END
#endif
#ifndef SvVSTRING_mg
# define SvVSTRING_mg(sv) (SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_vstring) : NULL)
#endif
/* Hint: sv_magic_portable
* This is a compatibility function that is only available with
* Devel::PPPort. It is NOT in the perl core.
* Its purpose is to mimic the 5.8.0 behaviour of sv_magic() when
* it is being passed a name pointer with namlen == 0. In that
* case, perl 5.8.0 and later store the pointer, not a copy of it.
* The compatibility can be provided back to perl 5.004. With
* earlier versions, the code will not compile.
*/
#if (PERL_BCDVERSION < 0x5004000)
/* code that uses sv_magic_portable will not compile */
#elif (PERL_BCDVERSION < 0x5008000)
# define sv_magic_portable(sv, obj, how, name, namlen) \
STMT_START { \
SV *SvMp_sv = (sv); \
char *SvMp_name = (char *) (name); \
I32 SvMp_namlen = (namlen); \
if (SvMp_name && SvMp_namlen == 0) \
{ \
MAGIC *mg; \
sv_magic(SvMp_sv, obj, how, 0, 0); \
mg = SvMAGIC(SvMp_sv); \
mg->mg_len = -42; /* XXX: this is the tricky part */ \
mg->mg_ptr = SvMp_name; \
} \
else \
{ \
sv_magic(SvMp_sv, obj, how, SvMp_name, SvMp_namlen); \
} \
} STMT_END
#else
# define sv_magic_portable(a, b, c, d, e) sv_magic(a, b, c, d, e)
#endif
#ifdef USE_ITHREADS
#ifndef CopFILE
# define CopFILE(c) ((c)->cop_file)
#endif
#ifndef CopFILEGV
# define CopFILEGV(c) (CopFILE(c) ? gv_fetchfile(CopFILE(c)) : Nullgv)
#endif
#ifndef CopFILE_set
# define CopFILE_set(c,pv) ((c)->cop_file = savepv(pv))
#endif
#ifndef CopFILESV
# define CopFILESV(c) (CopFILE(c) ? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv)
#endif
#ifndef CopFILEAV
# define CopFILEAV(c) (CopFILE(c) ? GvAV(gv_fetchfile(CopFILE(c))) : Nullav)
#endif
#ifndef CopSTASHPV
# define CopSTASHPV(c) ((c)->cop_stashpv)
#endif
#ifndef CopSTASHPV_set
# define CopSTASHPV_set(c,pv) ((c)->cop_stashpv = ((pv) ? savepv(pv) : Nullch))
#endif
#ifndef CopSTASH
# define CopSTASH(c) (CopSTASHPV(c) ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv)
#endif
#ifndef CopSTASH_set
# define CopSTASH_set(c,hv) CopSTASHPV_set(c, (hv) ? HvNAME(hv) : Nullch)
#endif
#ifndef CopSTASH_eq
# define CopSTASH_eq(c,hv) ((hv) && (CopSTASHPV(c) == HvNAME(hv) \
|| (CopSTASHPV(c) && HvNAME(hv) \
&& strEQ(CopSTASHPV(c), HvNAME(hv)))))
#endif
#else
#ifndef CopFILEGV
# define CopFILEGV(c) ((c)->cop_filegv)
#endif
#ifndef CopFILEGV_set
# define CopFILEGV_set(c,gv) ((c)->cop_filegv = (GV*)SvREFCNT_inc(gv))
#endif
#ifndef CopFILE_set
# define CopFILE_set(c,pv) CopFILEGV_set((c), gv_fetchfile(pv))
#endif
#ifndef CopFILESV
# define CopFILESV(c) (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv)
#endif
#ifndef CopFILEAV
# define CopFILEAV(c) (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav)
#endif
#ifndef CopFILE
# define CopFILE(c) (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch)
#endif
#ifndef CopSTASH
# define CopSTASH(c) ((c)->cop_stash)
#endif
#ifndef CopSTASH_set
# define CopSTASH_set(c,hv) ((c)->cop_stash = (hv))
#endif
#ifndef CopSTASHPV
# define CopSTASHPV(c) (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch)
#endif
#ifndef CopSTASHPV_set
# define CopSTASHPV_set(c,pv) CopSTASH_set((c), gv_stashpv(pv,GV_ADD))
#endif
#ifndef CopSTASH_eq
# define CopSTASH_eq(c,hv) (CopSTASH(c) == (hv))
#endif
#endif /* USE_ITHREADS */
#ifndef IN_PERL_COMPILETIME
# define IN_PERL_COMPILETIME (PL_curcop == &PL_compiling)
#endif
#ifndef IN_LOCALE_RUNTIME
# define IN_LOCALE_RUNTIME (PL_curcop->op_private & HINT_LOCALE)
#endif
#ifndef IN_LOCALE_COMPILETIME
# define IN_LOCALE_COMPILETIME (PL_hints & HINT_LOCALE)
#endif
#ifndef IN_LOCALE
# define IN_LOCALE (IN_PERL_COMPILETIME ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME)
#endif
#ifndef IS_NUMBER_IN_UV
# define IS_NUMBER_IN_UV 0x01
#endif
#ifndef IS_NUMBER_GREATER_THAN_UV_MAX
# define IS_NUMBER_GREATER_THAN_UV_MAX 0x02
#endif
#ifndef IS_NUMBER_NOT_INT
# define IS_NUMBER_NOT_INT 0x04
#endif
#ifndef IS_NUMBER_NEG
# define IS_NUMBER_NEG 0x08
#endif
#ifndef IS_NUMBER_INFINITY
# define IS_NUMBER_INFINITY 0x10
#endif
#ifndef IS_NUMBER_NAN
# define IS_NUMBER_NAN 0x20
#endif
#ifndef GROK_NUMERIC_RADIX
# define GROK_NUMERIC_RADIX(sp, send) grok_numeric_radix(sp, send)
#endif
#ifndef PERL_SCAN_GREATER_THAN_UV_MAX
# define PERL_SCAN_GREATER_THAN_UV_MAX 0x02
#endif
#ifndef PERL_SCAN_SILENT_ILLDIGIT
# define PERL_SCAN_SILENT_ILLDIGIT 0x04
#endif
#ifndef PERL_SCAN_ALLOW_UNDERSCORES
# define PERL_SCAN_ALLOW_UNDERSCORES 0x01
#endif
#ifndef PERL_SCAN_DISALLOW_PREFIX
# define PERL_SCAN_DISALLOW_PREFIX 0x02
#endif
#ifndef grok_numeric_radix
#if defined(NEED_grok_numeric_radix)
static bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send);
static
#else
extern bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send);
#endif
#ifdef grok_numeric_radix
# undef grok_numeric_radix
#endif
#define grok_numeric_radix(a,b) DPPP_(my_grok_numeric_radix)(aTHX_ a,b)
#define Perl_grok_numeric_radix DPPP_(my_grok_numeric_radix)
#if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL)
bool
DPPP_(my_grok_numeric_radix)(pTHX_ const char **sp, const char *send)
{
#ifdef USE_LOCALE_NUMERIC
#ifdef PL_numeric_radix_sv
if (PL_numeric_radix_sv && IN_LOCALE) {
STRLEN len;
char* radix = SvPV(PL_numeric_radix_sv, len);
if (*sp + len <= send && memEQ(*sp, radix, len)) {
*sp += len;
return TRUE;
}
}
#else
/* older perls don't have PL_numeric_radix_sv so the radix
* must manually be requested from locale.h
*/
#include
dTHR; /* needed for older threaded perls */
struct lconv *lc = localeconv();
char *radix = lc->decimal_point;
if (radix && IN_LOCALE) {
STRLEN len = strlen(radix);
if (*sp + len <= send && memEQ(*sp, radix, len)) {
*sp += len;
return TRUE;
}
}
#endif
#endif /* USE_LOCALE_NUMERIC */
/* always try "." if numeric radix didn't match because
* we may have data from different locales mixed */
if (*sp < send && **sp == '.') {
++*sp;
return TRUE;
}
return FALSE;
}
#endif
#endif
#ifndef grok_number
#if defined(NEED_grok_number)
static int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep);
static
#else
extern int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep);
#endif
#ifdef grok_number
# undef grok_number
#endif
#define grok_number(a,b,c) DPPP_(my_grok_number)(aTHX_ a,b,c)
#define Perl_grok_number DPPP_(my_grok_number)
#if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL)
int
DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep)
{
const char *s = pv;
const char *send = pv + len;
const UV max_div_10 = UV_MAX / 10;
const char max_mod_10 = UV_MAX % 10;
int numtype = 0;
int sawinf = 0;
int sawnan = 0;
while (s < send && isSPACE(*s))
s++;
if (s == send) {
return 0;
} else if (*s == '-') {
s++;
numtype = IS_NUMBER_NEG;
}
else if (*s == '+')
s++;
if (s == send)
return 0;
/* next must be digit or the radix separator or beginning of infinity */
if (isDIGIT(*s)) {
/* UVs are at least 32 bits, so the first 9 decimal digits cannot
overflow. */
UV value = *s - '0';
/* This construction seems to be more optimiser friendly.
(without it gcc does the isDIGIT test and the *s - '0' separately)
With it gcc on arm is managing 6 instructions (6 cycles) per digit.
In theory the optimiser could deduce how far to unroll the loop
before checking for overflow. */
if (++s < send) {
int digit = *s - '0';
if (digit >= 0 && digit <= 9) {
value = value * 10 + digit;
if (++s < send) {
digit = *s - '0';
if (digit >= 0 && digit <= 9) {
value = value * 10 + digit;
if (++s < send) {
digit = *s - '0';
if (digit >= 0 && digit <= 9) {
value = value * 10 + digit;
if (++s < send) {
digit = *s - '0';
if (digit >= 0 && digit <= 9) {
value = value * 10 + digit;
if (++s < send) {
digit = *s - '0';
if (digit >= 0 && digit <= 9) {
value = value * 10 + digit;
if (++s < send) {
digit = *s - '0';
if (digit >= 0 && digit <= 9) {
value = value * 10 + digit;
if (++s < send) {
digit = *s - '0';
if (digit >= 0 && digit <= 9) {
value = value * 10 + digit;
if (++s < send) {
digit = *s - '0';
if (digit >= 0 && digit <= 9) {
value = value * 10 + digit;
if (++s < send) {
/* Now got 9 digits, so need to check
each time for overflow. */
digit = *s - '0';
while (digit >= 0 && digit <= 9
&& (value < max_div_10
|| (value == max_div_10
&& digit <= max_mod_10))) {
value = value * 10 + digit;
if (++s < send)
digit = *s - '0';
else
break;
}
if (digit >= 0 && digit <= 9
&& (s < send)) {
/* value overflowed.
skip the remaining digits, don't
worry about setting *valuep. */
do {
s++;
} while (s < send && isDIGIT(*s));
numtype |=
IS_NUMBER_GREATER_THAN_UV_MAX;
goto skip_value;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
numtype |= IS_NUMBER_IN_UV;
if (valuep)
*valuep = value;
skip_value:
if (GROK_NUMERIC_RADIX(&s, send)) {
numtype |= IS_NUMBER_NOT_INT;
while (s < send && isDIGIT(*s)) /* optional digits after the radix */
s++;
}
}
else if (GROK_NUMERIC_RADIX(&s, send)) {
numtype |= IS_NUMBER_NOT_INT | IS_NUMBER_IN_UV; /* valuep assigned below */
/* no digits before the radix means we need digits after it */
if (s < send && isDIGIT(*s)) {
do {
s++;
} while (s < send && isDIGIT(*s));
if (valuep) {
/* integer approximation is valid - it's 0. */
*valuep = 0;
}
}
else
return 0;
} else if (*s == 'I' || *s == 'i') {
s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
s++; if (s == send || (*s != 'F' && *s != 'f')) return 0;
s++; if (s < send && (*s == 'I' || *s == 'i')) {
s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
s++; if (s == send || (*s != 'I' && *s != 'i')) return 0;
s++; if (s == send || (*s != 'T' && *s != 't')) return 0;
s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0;
s++;
}
sawinf = 1;
} else if (*s == 'N' || *s == 'n') {
/* XXX TODO: There are signaling NaNs and quiet NaNs. */
s++; if (s == send || (*s != 'A' && *s != 'a')) return 0;
s++; if (s == send || (*s != 'N' && *s != 'n')) return 0;
s++;
sawnan = 1;
} else
return 0;
if (sawinf) {
numtype &= IS_NUMBER_NEG; /* Keep track of sign */
numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT;
} else if (sawnan) {
numtype &= IS_NUMBER_NEG; /* Keep track of sign */
numtype |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT;
} else if (s < send) {
/* we can have an optional exponent part */
if (*s == 'e' || *s == 'E') {
/* The only flag we keep is sign. Blow away any "it's UV" */
numtype &= IS_NUMBER_NEG;
numtype |= IS_NUMBER_NOT_INT;
s++;
if (s < send && (*s == '-' || *s == '+'))
s++;
if (s < send && isDIGIT(*s)) {
do {
s++;
} while (s < send && isDIGIT(*s));
}
else
return 0;
}
}
while (s < send && isSPACE(*s))
s++;
if (s >= send)
return numtype;
if (len == 10 && memEQ(pv, "0 but true", 10)) {
if (valuep)
*valuep = 0;
return IS_NUMBER_IN_UV;
}
return 0;
}
#endif
#endif
/*
* The grok_* routines have been modified to use warn() instead of
* Perl_warner(). Also, 'hexdigit' was the former name of PL_hexdigit,
* which is why the stack variable has been renamed to 'xdigit'.
*/
#ifndef grok_bin
#if defined(NEED_grok_bin)
static UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result);
static
#else
extern UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result);
#endif
#ifdef grok_bin
# undef grok_bin
#endif
#define grok_bin(a,b,c,d) DPPP_(my_grok_bin)(aTHX_ a,b,c,d)
#define Perl_grok_bin DPPP_(my_grok_bin)
#if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL)
UV
DPPP_(my_grok_bin)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result)
{
const char *s = start;
STRLEN len = *len_p;
UV value = 0;
NV value_nv = 0;
const UV max_div_2 = UV_MAX / 2;
bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
bool overflowed = FALSE;
if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) {
/* strip off leading b or 0b.
for compatibility silently suffer "b" and "0b" as valid binary
numbers. */
if (len >= 1) {
if (s[0] == 'b') {
s++;
len--;
}
else if (len >= 2 && s[0] == '0' && s[1] == 'b') {
s+=2;
len-=2;
}
}
}
for (; len-- && *s; s++) {
char bit = *s;
if (bit == '0' || bit == '1') {
/* Write it in this wonky order with a goto to attempt to get the
compiler to make the common case integer-only loop pretty tight.
With gcc seems to be much straighter code than old scan_bin. */
redo:
if (!overflowed) {
if (value <= max_div_2) {
value = (value << 1) | (bit - '0');
continue;
}
/* Bah. We're just overflowed. */
warn("Integer overflow in binary number");
overflowed = TRUE;
value_nv = (NV) value;
}
value_nv *= 2.0;
/* If an NV has not enough bits in its mantissa to
* represent a UV this summing of small low-order numbers
* is a waste of time (because the NV cannot preserve
* the low-order bits anyway): we could just remember when
* did we overflow and in the end just multiply value_nv by the
* right amount. */
value_nv += (NV)(bit - '0');
continue;
}
if (bit == '_' && len && allow_underscores && (bit = s[1])
&& (bit == '0' || bit == '1'))
{
--len;
++s;
goto redo;
}
if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
warn("Illegal binary digit '%c' ignored", *s);
break;
}
if ( ( overflowed && value_nv > 4294967295.0)
#if UVSIZE > 4
|| (!overflowed && value > 0xffffffff )
#endif
) {
warn("Binary number > 0b11111111111111111111111111111111 non-portable");
}
*len_p = s - start;
if (!overflowed) {
*flags = 0;
return value;
}
*flags = PERL_SCAN_GREATER_THAN_UV_MAX;
if (result)
*result = value_nv;
return UV_MAX;
}
#endif
#endif
#ifndef grok_hex
#if defined(NEED_grok_hex)
static UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result);
static
#else
extern UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result);
#endif
#ifdef grok_hex
# undef grok_hex
#endif
#define grok_hex(a,b,c,d) DPPP_(my_grok_hex)(aTHX_ a,b,c,d)
#define Perl_grok_hex DPPP_(my_grok_hex)
#if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL)
UV
DPPP_(my_grok_hex)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result)
{
const char *s = start;
STRLEN len = *len_p;
UV value = 0;
NV value_nv = 0;
const UV max_div_16 = UV_MAX / 16;
bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
bool overflowed = FALSE;
const char *xdigit;
if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) {
/* strip off leading x or 0x.
for compatibility silently suffer "x" and "0x" as valid hex numbers.
*/
if (len >= 1) {
if (s[0] == 'x') {
s++;
len--;
}
else if (len >= 2 && s[0] == '0' && s[1] == 'x') {
s+=2;
len-=2;
}
}
}
for (; len-- && *s; s++) {
xdigit = strchr((char *) PL_hexdigit, *s);
if (xdigit) {
/* Write it in this wonky order with a goto to attempt to get the
compiler to make the common case integer-only loop pretty tight.
With gcc seems to be much straighter code than old scan_hex. */
redo:
if (!overflowed) {
if (value <= max_div_16) {
value = (value << 4) | ((xdigit - PL_hexdigit) & 15);
continue;
}
warn("Integer overflow in hexadecimal number");
overflowed = TRUE;
value_nv = (NV) value;
}
value_nv *= 16.0;
/* If an NV has not enough bits in its mantissa to
* represent a UV this summing of small low-order numbers
* is a waste of time (because the NV cannot preserve
* the low-order bits anyway): we could just remember when
* did we overflow and in the end just multiply value_nv by the
* right amount of 16-tuples. */
value_nv += (NV)((xdigit - PL_hexdigit) & 15);
continue;
}
if (*s == '_' && len && allow_underscores && s[1]
&& (xdigit = strchr((char *) PL_hexdigit, s[1])))
{
--len;
++s;
goto redo;
}
if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
warn("Illegal hexadecimal digit '%c' ignored", *s);
break;
}
if ( ( overflowed && value_nv > 4294967295.0)
#if UVSIZE > 4
|| (!overflowed && value > 0xffffffff )
#endif
) {
warn("Hexadecimal number > 0xffffffff non-portable");
}
*len_p = s - start;
if (!overflowed) {
*flags = 0;
return value;
}
*flags = PERL_SCAN_GREATER_THAN_UV_MAX;
if (result)
*result = value_nv;
return UV_MAX;
}
#endif
#endif
#ifndef grok_oct
#if defined(NEED_grok_oct)
static UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result);
static
#else
extern UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result);
#endif
#ifdef grok_oct
# undef grok_oct
#endif
#define grok_oct(a,b,c,d) DPPP_(my_grok_oct)(aTHX_ a,b,c,d)
#define Perl_grok_oct DPPP_(my_grok_oct)
#if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL)
UV
DPPP_(my_grok_oct)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result)
{
const char *s = start;
STRLEN len = *len_p;
UV value = 0;
NV value_nv = 0;
const UV max_div_8 = UV_MAX / 8;
bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES;
bool overflowed = FALSE;
for (; len-- && *s; s++) {
/* gcc 2.95 optimiser not smart enough to figure that this subtraction
out front allows slicker code. */
int digit = *s - '0';
if (digit >= 0 && digit <= 7) {
/* Write it in this wonky order with a goto to attempt to get the
compiler to make the common case integer-only loop pretty tight.
*/
redo:
if (!overflowed) {
if (value <= max_div_8) {
value = (value << 3) | digit;
continue;
}
/* Bah. We're just overflowed. */
warn("Integer overflow in octal number");
overflowed = TRUE;
value_nv = (NV) value;
}
value_nv *= 8.0;
/* If an NV has not enough bits in its mantissa to
* represent a UV this summing of small low-order numbers
* is a waste of time (because the NV cannot preserve
* the low-order bits anyway): we could just remember when
* did we overflow and in the end just multiply value_nv by the
* right amount of 8-tuples. */
value_nv += (NV)digit;
continue;
}
if (digit == ('_' - '0') && len && allow_underscores
&& (digit = s[1] - '0') && (digit >= 0 && digit <= 7))
{
--len;
++s;
goto redo;
}
/* Allow \octal to work the DWIM way (that is, stop scanning
* as soon as non-octal characters are seen, complain only iff
* someone seems to want to use the digits eight and nine). */
if (digit == 8 || digit == 9) {
if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT))
warn("Illegal octal digit '%c' ignored", *s);
}
break;
}
if ( ( overflowed && value_nv > 4294967295.0)
#if UVSIZE > 4
|| (!overflowed && value > 0xffffffff )
#endif
) {
warn("Octal number > 037777777777 non-portable");
}
*len_p = s - start;
if (!overflowed) {
*flags = 0;
return value;
}
*flags = PERL_SCAN_GREATER_THAN_UV_MAX;
if (result)
*result = value_nv;
return UV_MAX;
}
#endif
#endif
#if !defined(my_snprintf)
#if defined(NEED_my_snprintf)
static int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...);
static
#else
extern int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...);
#endif
#define my_snprintf DPPP_(my_my_snprintf)
#define Perl_my_snprintf DPPP_(my_my_snprintf)
#if defined(NEED_my_snprintf) || defined(NEED_my_snprintf_GLOBAL)
int
DPPP_(my_my_snprintf)(char *buffer, const Size_t len, const char *format, ...)
{
dTHX;
int retval;
va_list ap;
va_start(ap, format);
#ifdef HAS_VSNPRINTF
retval = vsnprintf(buffer, len, format, ap);
#else
retval = vsprintf(buffer, format, ap);
#endif
va_end(ap);
if (retval >= (int)len)
Perl_croak(aTHX_ "panic: my_snprintf buffer overflow");
return retval;
}
#endif
#endif
#ifdef NO_XSLOCKS
# ifdef dJMPENV
# define dXCPT dJMPENV; int rEtV = 0
# define XCPT_TRY_START JMPENV_PUSH(rEtV); if (rEtV == 0)
# define XCPT_TRY_END JMPENV_POP;
# define XCPT_CATCH if (rEtV != 0)
# define XCPT_RETHROW JMPENV_JUMP(rEtV)
# else
# define dXCPT Sigjmp_buf oldTOP; int rEtV = 0
# define XCPT_TRY_START Copy(top_env, oldTOP, 1, Sigjmp_buf); rEtV = Sigsetjmp(top_env, 1); if (rEtV == 0)
# define XCPT_TRY_END Copy(oldTOP, top_env, 1, Sigjmp_buf);
# define XCPT_CATCH if (rEtV != 0)
# define XCPT_RETHROW Siglongjmp(top_env, rEtV)
# endif
#endif
#if !defined(my_strlcat)
#if defined(NEED_my_strlcat)
static Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size);
static
#else
extern Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size);
#endif
#define my_strlcat DPPP_(my_my_strlcat)
#define Perl_my_strlcat DPPP_(my_my_strlcat)
#if defined(NEED_my_strlcat) || defined(NEED_my_strlcat_GLOBAL)
Size_t
DPPP_(my_my_strlcat)(char *dst, const char *src, Size_t size)
{
Size_t used, length, copy;
used = strlen(dst);
length = strlen(src);
if (size > 0 && used < size - 1) {
copy = (length >= size - used) ? size - used - 1 : length;
memcpy(dst + used, src, copy);
dst[used + copy] = '\0';
}
return used + length;
}
#endif
#endif
#if !defined(my_strlcpy)
#if defined(NEED_my_strlcpy)
static Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size);
static
#else
extern Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size);
#endif
#define my_strlcpy DPPP_(my_my_strlcpy)
#define Perl_my_strlcpy DPPP_(my_my_strlcpy)
#if defined(NEED_my_strlcpy) || defined(NEED_my_strlcpy_GLOBAL)
Size_t
DPPP_(my_my_strlcpy)(char *dst, const char *src, Size_t size)
{
Size_t length, copy;
length = strlen(src);
if (size > 0) {
copy = (length >= size) ? size - 1 : length;
memcpy(dst, src, copy);
dst[copy] = '\0';
}
return length;
}
#endif
#endif
#endif /* _P_P_PORTABILITY_H_ */
/* End of File ppport.h */
Cairo-1.109/t/ 000755 001750 000024 00000000000 14001743452 013255 5 ustar 00brian staff 000000 000000 Cairo-1.109/doctypes 000644 001750 000024 00000000351 11664366475 014610 0 ustar 00brian staff 000000 000000 cairo_t Cairo::Context
cairo_content_t Cairo::Content
cairo_font_options_t Cairo::FontOptions
cairo_font_type_t Cairo::FontType
cairo_pattern_t Cairo::Pattern
cairo_scaled_font_t Cairo::ScaledFont
cairo_surface_t Cairo::Surface
Cairo-1.109/README 000644 001750 000024 00000010132 12221731405 013664 0 ustar 00brian staff 000000 000000 Cairo
=====
Perl bindings to the cairo graphics library (http://www.cairographics.org).
INSTALLATION
------------
To install this module type the following:
perl Makefile.PL
make
make test
make install
To avoid installing to a system directory, if you don't have root access,
you can change the installation prefix at Makefile.PL time with
perl Makefile.PL PREFIX=/some/other/place
This will install the module to the subdirectory lib/perl5 under the given
prefix. If this is not already in perl's include path, you'll need to tell
perl how to get to this library directory so you can use it; there are three
ways:
in your environment (the easiest):
# assuming a bourne-style shell
PERL5LIB=/some/other/place/lib/perl5/site_perl
export PERL5LIB
on the perl command line:
perl -I /some/other/place/lib/perl5/site_perl yourscript
in the code of your perl script:
use lib '/some/other/place/lib/perl5/site_perl';
DEPENDENCIES
------------
This module requires these other modules and libraries:
cairo (C library) >= 1.0.0
In order to build it from source, you'll also need
ExtUtils::Depends >= 0.2
ExtUtils::PkgConfig >= 1.0
Test::Number::Delta >= 1.0
HOW TO CONTACT US
-----------------
Homepage: http://gtk2-perl.sourceforge.net/
Mailing list: gtk-perl-list [at] gnome.org
Mailing list archives: https://mail.gnome.org/archives/gtk-perl-list/
IRC: irc://irc.gnome.org/#gtk-perl
E-mail bug submission via CPAN's RT:
bug-Cairo [at] rt.cpan.org
Web bug submission via gnome.org's bugzilla:
http://bugzilla.gnome.org/enter_bug.cgi?product=gnome-perl
Please do not contact any of the maintainers directly unless they ask you to.
The first point of contact for questions/problems/issues should always be the
mailing list.
BUG REPORTS
-----------
For help with problems, please contact the mailing list (above). If you
already know you have a bug, please file it with one of the bug trackers
below. With any problems and/or bug reports, it's always helpful for the
developers to have the following information:
- A small script that demonstrates the problem; this is not required, however,
it will get your issue looked at much faster than a description of the
problem alone.
- Version of Perl (perl -v)
- Versions of Gtk2-Perl modules (Glib/Gtk2/Pango/Cairo)
- Optional, but nice to have: versions of GTK+ libraries on your system
(libglib, libgtk+, libpango, libcairo, etc.)
There are multiple project bug trackers, please choose the one you are most
comfortable with using and/or already have an account for.
Request Tracker:
- submitting bugs via the Web (requires a PAUSE account/Bitcard):
https://rt.cpan.org/Public/Bug/Report.html?Queue=Cairo
- submitting bugs via e-mail (open to anyone with e-mail):
bug-Cairo [at] rt.cpan.org
Gnome's bugtracker:
- report bugs to the 'gnome-perl' product (requires login)
http://bugzilla.gnome.org/enter_bug.cgi?product=gnome-perl
PATCH SUBMISSION GUIDELINES
---------------------------
You can send us patches by...
- E-mailing it to the mailing list (above); please use a pastebin service of
some kind for longer patchfiles (over say 20k in size).
- Those with gnome.org Git ID's can push trivial patches to git directly; if
you're not sure what a trivial patch is, please ask first on the mailing
list prior to pushing your commit.
OBTAINING SOURCE FROM THE GNOME.ORG GIT REPO
--------------------------------------------
Assuming you already have the 'git' command installed on your system, you can
use the 'git://' protocol:
git clone git://git.gnome.org/perl-Cairo
Or, read-only access via HTTP:
git clone http://git.gnome.org/browse/perl-Cairo
To update an existing clone of the source:
git pull
Most Linux distros package the 'git' command in a package called 'git-core'.
COPYRIGHT AND LICENSE
---------------------
Copyright (C) 2004-2013 by the cairo perl team
Ross McFarland rwmcfa1 at neces dot com
Torsten Schoenfeld kaffeetisch at gmx dot de
See the LICENSE file in the top-level directory of this distribution for the
full license terms.
Cairo-1.109/TODO 000644 001750 000024 00000000056 11664366475 013525 0 ustar 00brian staff 000000 000000 * Write examples.
* Complete the API listing.
Cairo-1.109/NEWS 000644 001750 000024 00000027760 14001743313 013521 0 ustar 00brian staff 000000 000000 Overview of changes in Cairo 1.109
==================================
* Remove PDF outline exports that do not exist
Overview of changes in Cairo 1.108
==================================
* Add missing status codes
* Add Perl bindings for Cairo surface mime type setting/getting and get extents
* Add bindings for PDF outline support
* Add example file for PDF outline support bindings
* Updated MANIFEST file with newly added files
* Makefile.PL: updated Git URLs
* Add defined constants for MIME types, pdf outlining, and tags
Overview of changes in Cairo 1.107
==================================
* Rename DOAP file to appease Gitlab
* Add bindings for cairo_tag_begin and cairo_tag_end
* Add a binding for cairo_pdf_surface_set_metadata
Overview of changes in Cairo 1.106
==================================
* Generate cairo-perl-auto.typemap and cairo-perl-auto.h in a deterministic
fashion
* Use the pthread compatibility workaround on NetBSD as well
* Fix a test failure in t/CairoFont.t
Overview of changes in Cairo 1.105
==================================
* Fix libpthread-related building issues on OpenBSD
Overview of changes in Cairo 1.104
==================================
* Avoid misusing the macro PL_na, thus preventing potential issues when Cairo
is used in conjunction with certain XS modules, among them XML::Parser and
String::Approx.
Overview of changes in Cairo 1.103
==================================
* Hush a few compiler warnings
* Updated copyright date
Overview of changes in Cairo 1.102
==================================
* Fix building with perl <= 5.14
* Prevent crashes on exit with Cairo::Path on perl 5.6.
Overview of changes in Cairo 1.101
==================================
* Properly specify our dependencies.
* Fix some erroneous POD links.
* Distribute a missing test file.
Overview of changes in Cairo 1.100
==================================
Since 1.08x (the previous stable series)
----------------------------------------
* Make "use Cairo x.yyy" work. This required renaming the old
Cairo::VERSION, a wrapper for CAIRO_VERSION, to Cairo::LIB_VERSION --
but we kept the old way of calling it working. Cairo::version,
Cairo::version_string and Cairo::VERSION_ENCODE got the same treatment
for consistency.
* Auto-upgrade strings to utf8. Note that this means that calling
utf8::encode() on strings before passing them into Cairo will now
yield doubly-encoded and thus broken strings. Also, having
utf8-encoded literals in your code without an accompanying "use utf8"
line will also lead to double encoding.
* Expand and improve the README and META.yml files.
* Many compilation and test suite fixes.
Since 1.091
-----------
* Do not assume that sizeof(void*) == sizeof(long)
* Calculate a string length more efficiently
* added updated README text for RT#74870
* Created %meta_merge which follows v2 of meta-spec
Overview of changes in Cairo 1.091
==================================
* Auto-upgrade strings to utf8. Note that this means that calling
utf8::encode() on strings before passing them into Cairo will now
yield doubly-encoded and thus broken strings. Also, having
utf8-encoded literals in your code without an accompanying "use utf8"
line will also lead to double encoding.
* Fix compiling and testing against older versions of cairo.
* Make the test suite more robust.
Overview of changes in Cairo 1.090
==================================
* Make "use Cairo x.yyy" work; fixes RT#72783. This required renaming the old
Cairo::VERSION, a wrapper for CAIRO_VERSION, to Cairo::LIB_VERSION -- but we
kept the old way of calling it working. Cairo::version,
Cairo::version_string and Cairo::VERSION_ENCODE got the same treatment for
consistency.
* Updated FSF LGPL notice address (RT#72664)
Overview of changes in Cairo 1.082
==================================
* Update the symbol export list for linking on win32
(https://bugzilla.gnome.org/show_bug.cgi?id=665265)
Overview of changes in Cairo 1.081
==================================
* Add a missing cairo_font_type_t value.
* Fix a test failure.
Overview of changes in Cairo 1.080
==================================
Since 1.06x
-----------
* Wrap new 1.8 and 1.10 API.
* Make Cairo::Pattern->set_extend, get_extend, set_filter and get_filter
available to all pattern types, not just surface patterns.
* Make it possible to modify and create paths.
Since 1.071
-----------
* Add support for missing operator types.
* Fix compilation agains perl 5.15.x.
Overview of changes in Cairo 1.071
==================================
* Add new API:
- recording surface
- region functions
- toy font face
- PDF version functions
- Cairo::in_clip
- Cairo::Surface::create_for_rectangle
* Make it possible to modify and create paths.
* Make Cairo::Surface::create_similar callable as a class-static method, for
consistency with Cairo::Surface::create_for_rectangle.
* Fix a few test failures.
* Add more examples.
Overview of changes in Cairo 1.070
==================================
* Wrap 1.8 API:
- cairo_show_text_glyphs
- cairo_scaled_font_text_to_glyphs and
cairo_scaled_font_get_scale_matrix
- cairo_surface_get_fallback_resolution and
cairo_surface_has_show_text_glyphs
* Make Cairo::Pattern->set_extend, get_extend, set_filter and get_filter
available to all pattern types, not just surface patterns.
* Fix a memory manage bug in Cairo::FtFontFace.
* Fix a bug in the enum conversion code that made it more lenient than
intended.
* Add a few examples.
* Fix a few test failures.
Overview of changes in Cairo 1.062
==================================
* Cairo::FtFontFace: Keep the FT_Face alive long enough to avoid
segfaults
* Add two new example programs
* Fix test failures
Overview of changes in Cairo 1.061
==================================
* Support the enum value CAIRO_FONT_TYPE_QUARTZ.
* Improve the documentation slightly.
* Fix a few test failures.
* Fix a few build issues.
Overview of changes in Cairo 1.060
==================================
Since 1.04x
-----------
* Wrap new API:
- cairo_has_current_point
- cairo_path_extents
- cairo_format_stride_for_width
- cairo_surface_copy_page and cairo_surface_show_page
- cairo_ps_surface_restrict_to_level, cairo_ps_get_levels, and
cairo_ps_level_to_string
- cairo_ps_surface_set_eps and cairo_ps_surface_get_eps
* Provide Cairo::FtFontFace::create which can be used with Font::FreeType.
* Complete the API listing POD.
Since 1.053
-----------
* Document new API.
Overview of changes in Cairo 1.053
==================================
* Wrap new API:
- cairo_has_current_point
Overview of changes in Cairo 1.052
==================================
* Adapt to API changes: cairo_surface_copy_page and cairo_surface_show_page
don't return cairo_status_t anymore.
* Wrap new API:
- cairo_path_extents
- cairo_format_stride_for_width
* Fix the tied interface for paths on perl 5.6.
Overview of changes in Cairo 1.051
==================================
* Fix memory allocation errors on win32. [T.J. Ferraro]
* Wrap new API:
- cairo_surface_copy_page and cairo_surface_show_page
- cairo_ps_surface_restrict_to_level, cairo_ps_get_levels, and
cairo_ps_level_to_string
- cairo_ps_surface_set_eps and cairo_ps_surface_get_eps
Overview of changes in Cairo 1.050
==================================
* Provide Cairo::FtFontFace::create which can be used with Font::FreeType.
* Add entries for the various kinds of surfaces to the API listing.
* Fix some test suite and build issues.
Overview of changes in Cairo 1.045
==================================
* Fix memory allocation errors on win32. [T.J. Ferraro]
Overview of changes in Cairo 1.044
==================================
* Add entries for the various kinds of surfaces to the API listing.
* Fix some test suite and build issues.
Overview of changes in Cairo 1.043
==================================
* Fix a few build and compatibility problems.
Overview of changes in Cairo 1.042
==================================
* Fix a few build and test failures.
Overview of changes in Cairo 1.041
==================================
* Use Test::Numer::Delta to make floating point tests more reliable.
Overview of changes in Cairo 1.040
==================================
* Re-add Cairo::Surface::finish.
* Add support for cairo_get_scaled_font.
* Document the new API.
Overview of changes in Cairo 1.031
==================================
* Track upstream API improvements.
* Fix enum error messages to display the correct list of allowed values.
* Fix a endianness-related test failure.
Overview of changes in Cairo 1.030
==================================
* Add support for new API:
- cairo_get_dash, cairo_copy_clip_rectangles, and cairo_clip_extents.
- cairo_pattern_get_rgba, cairo_pattern_get_surface,
cairo_pattern_get_color_stop_rgba, cairo_pattern_get_points, and
cairo_pattern_get_circles.
* Make Cairo::ImageSurface::get_data usable.
Overview of changes in Cairo 1.021
==================================
* Fix test failure.
Overview of changes in Cairo 1.02
=================================
* Fix a bug that caused the content type value 'content-alpha' to be
interpreted as just 'content'.
Overview of changes in Cairo 1.01
=================================
* Fix a few test failures.
Overview of changes in Cairo 1.00
=================================
* Improve compilation compatibility with cairo 1.0.x.
* Export public symbols on win32.
Overview of changes in Cairo 0.92
=================================
* Fix compilation and tests with cairo 1.0.x when the PDF and/or PS backend are
enabled. [Yaakov S]
* Fix a problem in the PNG stream stuff that occured with perl 5.8.8.
* Add an example that demonstrates the PNG stream stuff.
Overview of changes in Cairo 0.91
=================================
* Make it possible to use the bindings with cairo 1.0.x and later. This makes
it possible to drop the cairo requirement back to 1.0.0.
Overview of changes in Cairo 0.90
=================================
* Require cairo 1.2.0.
* Add support for SVG surfaces.
* Add Cairo::VERSION and Cairo::VERSION_ENCODE.
* Wrap CAIRO_FORMAT_RGB16_565.
* Remove Cairo::HAS_XLIB_SURFACE and HAS_FT_FONT.
Overview of changes in Cairo 0.04
=================================
* Remove the wrappers for cairo_pdf_surface_set_dpi and
cairo_ps_surface_set_dpi. Developers should use
cairo_surface_set_fallback_resolution instead.
* Improve the enum converters to produce more useful error messages.
* Wrap the streaming functions:
- cairo_surface_write_to_png_stream
- cairo_image_surface_create_from_png_stream
- cairo_pdf_surface_create_for_stream
- cairo_ps_surface_create_for_stream
* Wrap new API:
- cairo_version, cairo_version_string, cairo_push_group,
cairo_push_group_with_content, cairo_pop_group, cairo_pop_group_to_source,
cairo_new_sub_path, cairo_set_scaled_font, cairo_get_group_target
- cairo_font_face_get_type, cairo_scaled_font_get_type,
cairo_scaled_font_text_extents, cairo_scaled_font_get_font_face,
cairo_scaled_font_get_font_matrix, cairo_scaled_font_get_ctm,
cairo_scaled_font_get_font_options
- cairo_pattern_get_type
- cairo_surface_get_device_offset, cairo_surface_get_type,
cairo_surface_get_content, cairo_surface_set_fallback_resolution
- cairo_image_surface_get_data, cairo_image_surface_get_format,
cairo_image_surface_get_stride
- cairo_pdf_surface_set_size
- cairo_ps_surface_set_dpi, cairo_ps_surface_set_size,
cairo_ps_surface_dsc_comment, cairo_ps_surface_dsc_begin_setup,
cairo_ps_surface_dsc_begin_setup
* Port more examples from cairo-demo.
Overview of changes in Cairo 0.03
=================================
* Export a sane type conversion API for other modules to use.
* Add lots of documentation in the form of API listings.
* Add Cairo::SolidPattern::create_rgb and create_rgba.
Overview of changes in Cairo 0.02
=================================
* Fix compilation error that occured when the PS and PDF backends of cairo were
disabled. [Reported by Christopher Oezbek]
Overview of changes in Cairo 0.01
=================================
* Initial release.
Cairo-1.109/MANIFEST.SKIP 000644 001750 000024 00000000207 11664366475 014731 0 ustar 00brian staff 000000 000000 ~$
.*\.bak
blib
.*\.bs
build
.*\.c
\.git
MAINTAINERS$
Makefile$
Makefile\.old
MYMETA\..*$
.*\.o
pm_to_blib
.*\.png
.*\.swp
.*\.tar\.gz
Cairo-1.109/examples/ 000755 001750 000024 00000000000 14001743452 014630 5 ustar 00brian staff 000000 000000 Cairo-1.109/META.yml 000644 001750 000024 00000002014 14001743452 014260 0 ustar 00brian staff 000000 000000 ---
abstract: 'Perl interface to the cairo 2d vector graphics library'
author:
- unknown
- 'Cairo Perl Team '
build_requires:
ExtUtils::MakeMaker: '0'
configure_requires:
ExtUtils::Depends: '0.2'
ExtUtils::MakeMaker: '0'
ExtUtils::PkgConfig: '1'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010'
license: unknown
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: Cairo
no_index:
directory:
- t
- inc
file:
- inc/MakeHelper.pm
requires:
ExtUtils::Depends: '0.2'
ExtUtils::PkgConfig: '1'
resources:
MailingList: https://mail.gnome.org/mailman/listinfo/gtk-perl-list
bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=Cairo
homepage: http://gtk2-perl.sourceforge.net
license: http://www.gnu.org/licenses/lgpl-2.1.html
repository: https://gitlab.gnome.org/GNOME/perl-cairo.git
version: '1.109'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
Cairo-1.109/CairoRegion.xs 000644 001750 000024 00000006036 11664366475 015616 0 ustar 00brian staff 000000 000000 /*
* Copyright (c) 2011 by the cairo perl team (see the file README)
*
* Licensed under the LGPL, see LICENSE file for more information.
*
*/
#include
MODULE = Cairo::Region PACKAGE = Cairo::Region PREFIX = cairo_region_
void DESTROY (cairo_region_t * region);
CODE:
cairo_region_destroy (region);
# cairo_region_t * cairo_region_create (void);
# cairo_region_t * cairo_region_create_rectangle (const cairo_rectangle_int_t *rect);
# cairo_region_t * cairo_region_create_rectangles (const cairo_rectangle_int_t *rects, int count);
cairo_region_t_noinc *
cairo_region_create (class, ...)
CODE:
if (items == 1) {
RETVAL = cairo_region_create ();
} else if (items == 2) {
RETVAL = cairo_region_create_rectangle (SvCairoRectangleInt (ST (1)));
} else {
cairo_rectangle_int_t *rects;
int i, count;
count = items - 1;
Newz (0, rects, count, cairo_rectangle_int_t);
for (i = 1; i < items; i++) {
rects[i-1] = *SvCairoRectangleInt (ST (i));
}
RETVAL = cairo_region_create_rectangles (rects, count);
Safefree (rects);
}
OUTPUT:
RETVAL
cairo_status_t cairo_region_status (const cairo_region_t *region);
# void cairo_region_get_extents (const cairo_region_t *region, cairo_rectangle_int_t *extents);
cairo_rectangle_int_t *
cairo_region_get_extents (const cairo_region_t *region)
PREINIT:
cairo_rectangle_int_t rect;
CODE:
cairo_region_get_extents (region, &rect);
RETVAL = ▭
OUTPUT:
RETVAL
int cairo_region_num_rectangles (const cairo_region_t *region);
# void cairo_region_get_rectangle (const cairo_region_t *region, int nth, cairo_rectangle_int_t *rectangle);
cairo_rectangle_int_t *
cairo_region_get_rectangle (const cairo_region_t *region, int nth)
PREINIT:
cairo_rectangle_int_t rect;
CODE:
cairo_region_get_rectangle (region, nth, &rect);
RETVAL = ▭
OUTPUT:
RETVAL
cairo_bool_t cairo_region_is_empty (const cairo_region_t *region);
cairo_bool_t cairo_region_contains_point (const cairo_region_t *region, int x, int y);
cairo_region_overlap_t cairo_region_contains_rectangle (const cairo_region_t *region, const cairo_rectangle_int_t *rectangle);
cairo_bool_t cairo_region_equal (const cairo_region_t *a, const cairo_region_t *b);
void cairo_region_translate (cairo_region_t *region, int dx, int dy);
cairo_status_t cairo_region_intersect (cairo_region_t *dst, const cairo_region_t *other);
cairo_status_t cairo_region_intersect_rectangle (cairo_region_t *dst, const cairo_rectangle_int_t *rectangle);
cairo_status_t cairo_region_subtract (cairo_region_t *dst, const cairo_region_t *other);
cairo_status_t cairo_region_subtract_rectangle (cairo_region_t *dst, const cairo_rectangle_int_t *rectangle);
cairo_status_t cairo_region_union (cairo_region_t *dst, const cairo_region_t *other);
cairo_status_t cairo_region_union_rectangle (cairo_region_t *dst, const cairo_rectangle_int_t *rectangle);
cairo_status_t cairo_region_xor (cairo_region_t *dst, const cairo_region_t *other);
cairo_status_t cairo_region_xor_rectangle (cairo_region_t *dst, const cairo_rectangle_int_t *rectangle);
Cairo-1.109/lib/ 000755 001750 000024 00000000000 14001743452 013560 5 ustar 00brian staff 000000 000000 Cairo-1.109/Makefile.PL 000644 001750 000024 00000042620 14001613127 014763 0 ustar 00brian staff 000000 000000 #
# Copyright (c) 2004-2012 by the cairo perl team (see the file README)
#
# Licensed under the LGPL, see LICENSE file for more information.
#
# $Id$
#
BEGIN { require 5.006; }
use strict;
use warnings;
use ExtUtils::MakeMaker;
require './inc/MakeHelper.pm';
my %extreqs = (
'cairo' => '1.0.0',
);
# Unfortunately we already need these prereqs for writing the Makefile ...
my %prereqs = (
'ExtUtils::Depends' => 0.2,
'ExtUtils::PkgConfig' => 1.0,
);
my %meta_merge = (
q(meta-spec) => {
version => '2',
url => 'http://search.cpan.org/perldoc?CPAN::Meta::Spec',
},
author =>
['Cairo Perl Team '],
release_status => 'stable',
# valid values: https://metacpan.org/module/CPAN::Meta::Spec#license
license => 'lgpl_2_1',
resources => {
license => 'http://www.gnu.org/licenses/lgpl-2.1.html',
homepage => 'http://gtk2-perl.sourceforge.net',
x_MailingList =>
'https://mail.gnome.org/mailman/listinfo/gtk-perl-list',
bugtracker => {
web =>
'http://rt.cpan.org/Public/Dist/Display.html?Name=Cairo',
mailto => 'bug-Cairo [at] rt.cpan.org',
},
repository => {
url => 'https://gitlab.gnome.org/GNOME/perl-cairo.git',
type => 'git',
web => 'https://gitlab.gnome.org/GNOME/perl-cairo',
},
},
prereqs => {
configure => {
requires => {%prereqs}, # no direct ref for 5.14 compatibility
},
test => {
recommends => {
'Test::Number::Delta' => 1.0,
},
},
},
no_index => {
file => [qw(inc/MakeHelper.pm)],
},
);
# ... thus we have to make sure they are installed.
while ((my $module, my $version) = each(%prereqs)) {
unless (eval "use $module $version; 1" ) {
print "This module requires $module to install itself.\n";
my $yn = ExtUtils::MakeMaker::prompt(" Install $module from CPAN?", 'n');
unless ($yn =~ /^y/i) {
die " *** Cannot install without $module. Exiting ...\n";
}
require Cwd;
require File::Spec;
require CPAN;
# Save this 'cause CPAN will chdir all over the place.
my $cwd = Cwd::cwd();
my $makefile = File::Spec->rel2abs($0);
CPAN::Shell->install($module);
chdir $cwd
or die "Cannot chdir() back to $cwd: $!";
}
eval "use $module $version; 1" or die $@;
}
my $autogen_dir = 'build';
mkdir $autogen_dir unless (-d $autogen_dir);
$MakeHelper::autogen_dir = $autogen_dir;
my %cairo_cfg;
eval { %cairo_cfg = ExtUtils::PkgConfig->find ("cairo >= $extreqs{cairo}"); };
if ($@ ne '') {
warn $@;
exit 0;
}
my %objects = (
'cairo_t *' => 'Cairo::Context',
'cairo_font_face_t *' => 'Cairo::FontFace',
'cairo_pattern_t *' => 'Cairo::Pattern',
'cairo_region_t *' => 'Cairo::Region',
'cairo_scaled_font_t *' => 'Cairo::ScaledFont',
'cairo_surface_t *' => 'Cairo::Surface',
);
my %structs = (
'cairo_font_options_t *' => 'Cairo::FontOptions',
'cairo_matrix_t *' => 'Cairo::Matrix',
'cairo_rectangle_t *' => 'Cairo::Rectangle',
'cairo_rectangle_int_t *' => 'Cairo::RectangleInt',
);
my %enums = (
cairo_antialias_t => [qw/
CAIRO_ANTIALIAS_
CAIRO_ANTIALIAS_DEFAULT
CAIRO_ANTIALIAS_NONE
CAIRO_ANTIALIAS_GRAY
CAIRO_ANTIALIAS_SUBPIXEL
/],
cairo_content_t => [qw/
CAIRO_CONTENT_
CAIRO_CONTENT_COLOR
CAIRO_CONTENT_ALPHA
CAIRO_CONTENT_COLOR_ALPHA
/],
cairo_extend_t => [qw/
CAIRO_EXTEND_
CAIRO_EXTEND_NONE
CAIRO_EXTEND_REPEAT
CAIRO_EXTEND_REFLECT
/],
cairo_fill_rule_t => [qw/
CAIRO_FILL_RULE_
CAIRO_FILL_RULE_WINDING
CAIRO_FILL_RULE_EVEN_ODD
/],
cairo_filter_t => [qw/
CAIRO_FILTER_
CAIRO_FILTER_FAST
CAIRO_FILTER_GOOD
CAIRO_FILTER_BEST
CAIRO_FILTER_NEAREST
CAIRO_FILTER_BILINEAR
CAIRO_FILTER_GAUSSIAN
/],
cairo_font_slant_t => [qw/
CAIRO_FONT_SLANT_
CAIRO_FONT_SLANT_NORMAL
CAIRO_FONT_SLANT_ITALIC
CAIRO_FONT_SLANT_OBLIQUE
/],
cairo_font_weight_t => [qw/
CAIRO_FONT_WEIGHT_
CAIRO_FONT_WEIGHT_NORMAL
CAIRO_FONT_WEIGHT_BOLD
/],
cairo_format_t => [qw/
CAIRO_FORMAT_
CAIRO_FORMAT_ARGB32
CAIRO_FORMAT_RGB24
CAIRO_FORMAT_A8
CAIRO_FORMAT_A1
/],
cairo_hint_metrics_t => [qw/
CAIRO_HINT_METRICS_
CAIRO_HINT_METRICS_DEFAULT
CAIRO_HINT_METRICS_OFF
CAIRO_HINT_METRICS_ON
/],
cairo_hint_style_t => [qw/
CAIRO_HINT_STYLE_
CAIRO_HINT_STYLE_DEFAULT
CAIRO_HINT_STYLE_NONE
CAIRO_HINT_STYLE_SLIGHT
CAIRO_HINT_STYLE_MEDIUM
CAIRO_HINT_STYLE_FULL
/],
cairo_line_cap_t => [qw/
CAIRO_LINE_CAP_
CAIRO_LINE_CAP_BUTT
CAIRO_LINE_CAP_ROUND
CAIRO_LINE_CAP_SQUARE
/],
cairo_line_join_t => [qw/
CAIRO_LINE_JOIN_
CAIRO_LINE_JOIN_MITER
CAIRO_LINE_JOIN_ROUND
CAIRO_LINE_JOIN_BEVEL
/],
cairo_operator_t => [qw/
CAIRO_OPERATOR_
CAIRO_OPERATOR_CLEAR
CAIRO_OPERATOR_SOURCE
CAIRO_OPERATOR_OVER
CAIRO_OPERATOR_IN
CAIRO_OPERATOR_OUT
CAIRO_OPERATOR_ATOP
CAIRO_OPERATOR_DEST
CAIRO_OPERATOR_DEST_OVER
CAIRO_OPERATOR_DEST_IN
CAIRO_OPERATOR_DEST_OUT
CAIRO_OPERATOR_DEST_ATOP
CAIRO_OPERATOR_XOR
CAIRO_OPERATOR_ADD
CAIRO_OPERATOR_SATURATE
/],
cairo_path_data_type_t => [qw/
CAIRO_PATH_
CAIRO_PATH_MOVE_TO
CAIRO_PATH_LINE_TO
CAIRO_PATH_CURVE_TO
CAIRO_PATH_CLOSE_PATH
/],
cairo_status_t => [qw/
CAIRO_STATUS_
CAIRO_STATUS_SUCCESS
CAIRO_STATUS_NO_MEMORY
CAIRO_STATUS_INVALID_RESTORE
CAIRO_STATUS_INVALID_POP_GROUP
CAIRO_STATUS_NO_CURRENT_POINT
CAIRO_STATUS_INVALID_MATRIX
CAIRO_STATUS_INVALID_STATUS
CAIRO_STATUS_NULL_POINTER
CAIRO_STATUS_INVALID_STRING
CAIRO_STATUS_INVALID_PATH_DATA
CAIRO_STATUS_READ_ERROR
CAIRO_STATUS_WRITE_ERROR
CAIRO_STATUS_SURFACE_FINISHED
CAIRO_STATUS_SURFACE_TYPE_MISMATCH
CAIRO_STATUS_PATTERN_TYPE_MISMATCH
CAIRO_STATUS_INVALID_CONTENT
CAIRO_STATUS_INVALID_FORMAT
CAIRO_STATUS_INVALID_VISUAL
CAIRO_STATUS_FILE_NOT_FOUND
CAIRO_STATUS_INVALID_DASH
/],
cairo_subpixel_order_t => [qw/
CAIRO_SUBPIXEL_ORDER_
CAIRO_SUBPIXEL_ORDER_DEFAULT
CAIRO_SUBPIXEL_ORDER_RGB
CAIRO_SUBPIXEL_ORDER_BGR
CAIRO_SUBPIXEL_ORDER_VRGB
CAIRO_SUBPIXEL_ORDER_VBGR
/],
);
my %flags = ();
# --------------------------------------------------------------------------- #
my @exports = qw(
cairo_font_face_to_sv
cairo_font_type_from_sv
cairo_font_type_to_sv
cairo_object_from_sv
cairo_object_to_sv
cairo_pattern_to_sv
cairo_struct_from_sv
cairo_struct_to_sv
cairo_surface_to_sv
newSVCairoGlyph
SvCairoGlyph
newSVCairoPath
SvCairoPath
newSVCairoFontExtents
newSVCairoTextExtents
cairo_antialias_from_sv
cairo_antialias_to_sv
cairo_content_from_sv
cairo_content_to_sv
cairo_extend_from_sv
cairo_extend_to_sv
cairo_fill_rule_from_sv
cairo_fill_rule_to_sv
cairo_filter_from_sv
cairo_filter_to_sv
cairo_font_slant_from_sv
cairo_font_slant_to_sv
cairo_font_weight_from_sv
cairo_font_weight_to_sv
cairo_format_from_sv
cairo_format_to_sv
cairo_hint_metrics_from_sv
cairo_hint_metrics_to_sv
cairo_hint_style_from_sv
cairo_hint_style_to_sv
cairo_line_cap_from_sv
cairo_line_cap_to_sv
cairo_line_join_from_sv
cairo_line_join_to_sv
cairo_operator_from_sv
cairo_operator_to_sv
cairo_path_data_type_from_sv
cairo_path_data_type_to_sv
cairo_status_from_sv
cairo_status_to_sv
cairo_subpixel_order_from_sv
cairo_subpixel_order_to_sv
);
# --------------------------------------------------------------------------- #
sub add_new_enum_values {
my (%new) = @_;
foreach my $enum (keys %new) {
foreach my $value (@{$new{$enum}}) {
push @{$enums{$enum}}, $value;
}
}
}
my $have_cairo_1_2 = ExtUtils::PkgConfig->atleast_version("cairo", "1.2.0");
my $have_cairo_1_4 = ExtUtils::PkgConfig->atleast_version("cairo", "1.4.0");
my $have_cairo_1_6 = ExtUtils::PkgConfig->atleast_version("cairo", "1.6.0");
my $have_cairo_1_8 = ExtUtils::PkgConfig->atleast_version("cairo", "1.8.0");
my $have_cairo_1_10 = ExtUtils::PkgConfig->atleast_version("cairo", "1.10.0");
my $have_cairo_1_12 = ExtUtils::PkgConfig->atleast_version("cairo", "1.12.0");
my $have_cairo_1_14 = ExtUtils::PkgConfig->atleast_version("cairo", "1.14.0");
my $have_cairo_1_16 = ExtUtils::PkgConfig->atleast_version("cairo", "1.16.0");
if ($have_cairo_1_2) {
add_new_enum_values(
cairo_extend_t => [qw/CAIRO_EXTEND_PAD/],
cairo_format_t => [qw/CAIRO_FORMAT_RGB16_565/],
cairo_status_t => [qw/CAIRO_STATUS_INVALID_DSC_COMMENT/],
);
$enums{cairo_font_type_t} = [qw/
CAIRO_FONT_TYPE_
CAIRO_FONT_TYPE_TOY
CAIRO_FONT_TYPE_FT
CAIRO_FONT_TYPE_WIN32
CAIRO_FONT_TYPE_ATSUI
/];
$enums{cairo_pattern_type_t} = [qw/
CAIRO_PATTERN_TYPE_
CAIRO_PATTERN_TYPE_SOLID
CAIRO_PATTERN_TYPE_SURFACE
CAIRO_PATTERN_TYPE_LINEAR
CAIRO_PATTERN_TYPE_RADIAL
/];
$enums{cairo_surface_type_t} = [qw/
CAIRO_SURFACE_TYPE_
CAIRO_SURFACE_TYPE_IMAGE
CAIRO_SURFACE_TYPE_PDF
CAIRO_SURFACE_TYPE_PS
CAIRO_SURFACE_TYPE_XLIB
CAIRO_SURFACE_TYPE_XCB
CAIRO_SURFACE_TYPE_GLITZ
CAIRO_SURFACE_TYPE_QUARTZ
CAIRO_SURFACE_TYPE_WIN32
CAIRO_SURFACE_TYPE_BEOS
CAIRO_SURFACE_TYPE_DIRECTFB
CAIRO_SURFACE_TYPE_SVG
/];
$enums{cairo_svg_version_t} = [qw/
CAIRO_SVG_VERSION_
CAIRO_SVG_VERSION_1_1
CAIRO_SVG_VERSION_1_2
/];
push @exports, qw/cairo_font_type_from_sv
cairo_font_type_to_sv
cairo_pattern_type_from_sv
cairo_pattern_type_to_sv
cairo_surface_type_from_sv
cairo_surface_type_to_sv
cairo_svg_version_from_sv
cairo_svg_version_to_sv/;
} else {
# We need to create empty enum entries for new types so that typemaps
# are generated for them. xsubpp demands typemaps even if the code is
# #if'd out.
$enums{cairo_font_type_t} = [];
$enums{cairo_pattern_type_t} = [];
$enums{cairo_surface_type_t} = [];
$enums{cairo_svg_version_t} = [];
}
if ($have_cairo_1_4) {
add_new_enum_values(
cairo_status_t => [qw/CAIRO_STATUS_INVALID_INDEX
CAIRO_STATUS_CLIP_NOT_REPRESENTABLE/],
cairo_surface_type_t => [qw/CAIRO_SURFACE_TYPE_OS2/],
);
push @exports, qw/newSVCairoRectangle
SvCairoRectangle/;
}
if ($have_cairo_1_6) {
add_new_enum_values(
cairo_font_type_t => [qw/CAIRO_FONT_TYPE_QUARTZ/],
cairo_status_t => [qw/CAIRO_STATUS_TEMP_FILE_ERROR
CAIRO_STATUS_INVALID_STRIDE/],
cairo_surface_type_t => [qw/CAIRO_SURFACE_TYPE_WIN32_PRINTING
CAIRO_SURFACE_TYPE_QUARTZ_IMAGE/],
);
$enums{cairo_ps_level_t} = [qw/
CAIRO_PS_LEVEL_
CAIRO_PS_LEVEL_2
CAIRO_PS_LEVEL_3
/];
push @exports, qw/cairo_ps_level_from_sv
cairo_ps_level_to_sv/;
} else {
$enums{cairo_ps_level_t} = [];
}
if ($have_cairo_1_8) {
add_new_enum_values(
cairo_status_t => [qw/CAIRO_STATUS_FONT_TYPE_MISMATCH
CAIRO_STATUS_USER_FONT_IMMUTABLE
CAIRO_STATUS_USER_FONT_ERROR
CAIRO_STATUS_NEGATIVE_COUNT
CAIRO_STATUS_INVALID_CLUSTERS
CAIRO_STATUS_INVALID_SLANT
CAIRO_STATUS_INVALID_WEIGHT/],
cairo_font_type_t => [qw/CAIRO_FONT_TYPE_USER/],
);
$flags{cairo_text_cluster_flags_t} = [qw/
CAIRO_TEXT_CLUSTER_FLAG_
CAIRO_TEXT_CLUSTER_FLAG_BACKWARD
/];
push @exports, qw/newSVCairoTextCluster
SvCairoTextCluster
cairo_text_cluster_flags_from_sv
cairo_text_cluster_flags_to_sv/;
} else {
$flags{cairo_text_cluster_flags_t} = [];
}
if ($have_cairo_1_10) {
add_new_enum_values(
cairo_status_t => [qw/CAIRO_STATUS_INVALID_SIZE
CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED
CAIRO_STATUS_DEVICE_TYPE_MISMATCH
CAIRO_STATUS_DEVICE_ERROR/],
cairo_surface_type_t => [
qw/CAIRO_SURFACE_TYPE_SCRIPT
CAIRO_SURFACE_TYPE_QT
CAIRO_SURFACE_TYPE_RECORDING
CAIRO_SURFACE_TYPE_VG
CAIRO_SURFACE_TYPE_GL
CAIRO_SURFACE_TYPE_DRM
CAIRO_SURFACE_TYPE_TEE
CAIRO_SURFACE_TYPE_XML
CAIRO_SURFACE_TYPE_SKIA
CAIRO_SURFACE_TYPE_SUBSURFACE/],
cairo_operator_t => [
qw/CAIRO_OPERATOR_MULTIPLY
CAIRO_OPERATOR_SCREEN
CAIRO_OPERATOR_OVERLAY
CAIRO_OPERATOR_DARKEN
CAIRO_OPERATOR_LIGHTEN
CAIRO_OPERATOR_COLOR_DODGE
CAIRO_OPERATOR_COLOR_BURN
CAIRO_OPERATOR_HARD_LIGHT
CAIRO_OPERATOR_SOFT_LIGHT
CAIRO_OPERATOR_DIFFERENCE
CAIRO_OPERATOR_EXCLUSION
CAIRO_OPERATOR_HSL_HUE
CAIRO_OPERATOR_HSL_SATURATION
CAIRO_OPERATOR_HSL_COLOR
CAIRO_OPERATOR_HSL_LUMINOSITY/],
);
$enums{cairo_pdf_version_t} = [qw/
CAIRO_PDF_VERSION_
CAIRO_PDF_VERSION_1_4
CAIRO_PDF_VERSION_1_5
/];
$enums{cairo_region_overlap_t} = [qw/
CAIRO_REGION_OVERLAP_
CAIRO_REGION_OVERLAP_IN
CAIRO_REGION_OVERLAP_OUT
CAIRO_REGION_OVERLAP_PART
/];
push @exports, qw/newSVCairoRectangleInt
SvCairoRectangleInt
cairo_pdf_version_from_sv
cairo_pdf_version_to_sv
cairo_region_overlap_from_sv
cairo_region_overlap_to_sv/;
} else {
$enums{cairo_pdf_version_t} = [];
$enums{cairo_region_overlap_t} = [];
}
if ($have_cairo_1_12) {
add_new_enum_values(
cairo_status_t => [qw/CAIRO_STATUS_INVALID_MESH_CONSTRUCTION
CAIRO_STATUS_DEVICE_FINISHED/],
);
} else {
}
if ($have_cairo_1_14) {
add_new_enum_values(
cairo_status_t => [qw/CAIRO_STATUS_JBIG2_GLOBAL_MISSING/],
);
} else {
}
if ($have_cairo_1_16) {
add_new_enum_values(
cairo_status_t => [qw/CAIRO_STATUS_PNG_ERROR
CAIRO_STATUS_FREETYPE_ERROR
CAIRO_STATUS_WIN32_GDI_ERROR
CAIRO_STATUS_TAG_ERROR/],
);
$enums{cairo_pdf_metadata_t} = [qw/
CAIRO_PDF_METADATA_
CAIRO_PDF_METADATA_TITLE
CAIRO_PDF_METADATA_AUTHOR
CAIRO_PDF_METADATA_SUBJECT
CAIRO_PDF_METADATA_KEYWORDS
CAIRO_PDF_METADATA_CREATOR
CAIRO_PDF_METADATA_CREATE_DATE
CAIRO_PDF_METADATA_MOD_DATE
/];
$flags{cairo_pdf_outline_flags_t} = [qw/
CAIRO_PDF_OUTLINE_FLAG_
CAIRO_PDF_OUTLINE_FLAG_OPEN
CAIRO_PDF_OUTLINE_FLAG_BOLD
CAIRO_PDF_OUTLINE_FLAG_ITALIC
/];
push @exports, qw/
cairo_pdf_outline_flags_from_sv
cairo_pdf_outline_flags_to_sv/;
} else {
$enums{cairo_pdf_metadata_t} = [];
$flags{cairo_pdf_outline_flags_t} = [];
}
# --------------------------------------------------------------------------- #
my %object_guards = (
cairo_region_t => '#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)',
);
my %struct_guards = (
cairo_rectangle_t => '#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)',
cairo_rectangle_int_t => '#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)',
);
my %enum_guards = (
cairo_ps_level_t => '#ifdef CAIRO_HAS_PS_SURFACE',
cairo_svg_version_t => '#ifdef CAIRO_HAS_SVG_SURFACE',
);
my %flag_guards = ();
MakeHelper::do_enums (\%enums, \%enum_guards);
MakeHelper::do_flags (\%flags, \%flag_guards);
my @xs_files = qw(
Cairo.xs
CairoFont.xs
CairoMatrix.xs
CairoPath.xs
CairoPattern.xs
CairoSurface.xs
);
if ($have_cairo_1_10) {
push @xs_files, 'CairoRegion.xs';
}
my $have_cairo_ft = !system qw(pkg-config --exists --silence-errors cairo-ft);
if ($have_cairo_ft) {
print "Compiling Cairo with FreeType support\n";
push @xs_files, 'CairoFt.xs';
my %ft_cfg = ExtUtils::PkgConfig->find ('cairo-ft');
$cairo_cfg{cflags} .= ' '.$ft_cfg{cflags};
$cairo_cfg{libs} .= ' '.$ft_cfg{libs};
}
MakeHelper::write_boot (
xs_files => \@xs_files,
ignore => '^Cairo$',
);
my @typemaps = MakeHelper::do_typemaps (\%objects, \%structs, \%enums, \%flags,
\%object_guards,
\%struct_guards,
\%enum_guards,
\%flag_guards);
push @typemaps, 'cairo-perl.typemap';
my $dep = ExtUtils::Depends->new ('Cairo');
$dep->set_inc ('-I. -I'.$autogen_dir.' '.$cairo_cfg{cflags});
$dep->set_libs ($cairo_cfg{libs});
$dep->add_xs (@xs_files);
$dep->add_c (qw/cairo-perl-enums.c cairo-perl-flags.c/);
$dep->add_pm ('lib/Cairo.pm' => '$(INST_LIBDIR)/Cairo.pm');
$dep->add_typemaps (@typemaps);
$dep->install (qw(cairo-perl.h
cairo-perl.typemap
doctypes
build/cairo-perl-auto.h
build/cairo-perl-auto.typemap));
$dep->save_config ('build/IFiles.pm');
# On OpenBSD/NetBSD, any program that directly or indirectly wants to load
# libpthread.so must do so from the start. But when perl is built without
# ithreads, it will also most likely not be compiled with "-pthread". When
# libcairo then goes and tries to load libpthread.so, the loader will error
# out.
my @bsd_compat_flags = ();
if (($^O eq 'openbsd' || $^O eq 'netbsd') && $Config::Config{ldflags} !~ m/-pthread\b/) {
warn " ***\n *** on OpenBSD/NetBSD, we either need perl linked with '-pthread',\n",
" *** or we need to set LD_PRELOAD=libpthread.so; doing the latter now...\n ***\n";
@bsd_compat_flags = (
macro => {FULLPERLRUN => 'LD_PRELOAD=libpthread.so $(FULLPERL)'},
);
}
WriteMakefile (
NAME => 'Cairo',
#AUTHOR, LICENSE are now part of %meta_merge
VERSION_FROM => 'lib/Cairo.pm',
ABSTRACT_FROM => 'lib/Cairo.pm',
PREREQ_PM => \%prereqs,
XSPROTOARG => '-noprototypes',
FUNCLIST => \@exports,
DL_FUNCS => { Cairo=> [] },
META_MERGE => \%meta_merge,
$dep->get_makefile_vars,
@bsd_compat_flags,
);
sub MY::postamble
{
my $autogen_dir = $MakeHelper::autogen_dir;
"realclean ::
-\$(RM_RF) $autogen_dir cairo-perl-enums.*";
}
Cairo-1.109/CairoPath.xs 000644 001750 000024 00000026161 12060470562 015250 0 ustar 00brian staff 000000 000000 /*
* Copyright (c) 2004-2011 by the cairo perl team (see the file README)
*
* Licensed under the LGPL, see LICENSE file for more information.
*
* $Id$
*/
#include
#include
#include "ppport.h"
#define MY_MAGIC_SIG 0xCAFE /* Let's hope this is unique enough */
static MAGIC *
cairo_perl_mg_find (SV *sv, int type)
{
if (sv) {
MAGIC *mg;
for (mg = SvMAGIC (sv); mg; mg = mg->mg_moremagic) {
if (mg->mg_type == type && mg->mg_private == MY_MAGIC_SIG)
return mg;
}
}
return NULL;
}
static void *
cairo_perl_mg_get (SV * sv)
{
MAGIC * mg;
if (!cairo_perl_sv_is_ref (sv) ||
!(mg = cairo_perl_mg_find (SvRV (sv), PERL_MAGIC_ext)))
return NULL;
return mg->mg_ptr;
}
/* ------------------------------------------------------------------------- */
static SV *
create_tie (SV * sv, void * object, const char * package)
{
SV * tie;
HV * stash;
MAGIC * mg;
/* Create a tied reference. */
tie = newRV_noinc (sv);
stash = gv_stashpv (package, TRUE);
sv_bless (tie, stash);
sv_magic (sv, tie, PERL_MAGIC_tied, Nullch, 0);
/* Associate the array with the original path via magic. */
sv_magic (sv, 0, PERL_MAGIC_ext, (const char *) object, 0);
mg = mg_find (sv, PERL_MAGIC_ext);
/* Mark the mg as belonging to us. */
mg->mg_private = MY_MAGIC_SIG;
#if PERL_REVISION <= 5 && PERL_VERSION <= 6
/* perl 5.6.x doesn't actually set mg_ptr when namlen == 0, so do it
* now. */
mg->mg_ptr = (char *) object;
#endif /* 5.6.x */
return tie;
}
static SV *
create_tied_av (void * object, const char * package)
{
return create_tie ((SV *) newAV (), object, package);
}
static SV *
create_tied_hv (void * object, const char * package)
{
return create_tie ((SV *) newHV (), object, package);
}
/* ------------------------------------------------------------------------- */
#define FETCH_POINT(i) \
if ((svp = av_fetch (points, i, 0)) && \
cairo_perl_sv_is_defined (*svp)) \
{ \
point = (AV *) SvRV (*svp); \
if ((svp = av_fetch (point, 0, 0))) \
data[i+1].point.x = SvNV (*svp); \
if ((svp = av_fetch (point, 1, 0))) \
data[i+1].point.y = SvNV (*svp); \
}
static void
fill_data_from_array (cairo_path_data_t * data, cairo_path_data_type_t type, AV * points)
{
SV ** svp;
AV * point;
switch (type) {
case CAIRO_PATH_MOVE_TO:
data->header.type = CAIRO_PATH_MOVE_TO;
data->header.length = 2;
FETCH_POINT (0);
break;
case CAIRO_PATH_LINE_TO:
data->header.type = CAIRO_PATH_LINE_TO;
data->header.length = 2;
FETCH_POINT (0);
break;
case CAIRO_PATH_CURVE_TO:
data->header.type = CAIRO_PATH_CURVE_TO;
data->header.length = 4;
FETCH_POINT (0);
FETCH_POINT (1);
FETCH_POINT (2);
break;
case CAIRO_PATH_CLOSE_PATH:
data->header.type = CAIRO_PATH_CLOSE_PATH;
data->header.length = 1;
break;
}
}
/* This uses cairo_perl_alloc_temp. So the return value is only valid until
* the next FREETMPS occurs. At the moment, the only cairo function that
* *takes* a cairo_path_t is cairo_append_path, and it acts on the path
* immediately and does not store it. So that's fine. */
static cairo_path_t *
path_from_array (SV * sv)
{
AV *av;
int i, num_data;
cairo_path_t *path;
cairo_path_data_t *data;
if (!cairo_perl_sv_is_array_ref (sv))
croak ("a Cairo::Path has to be an array reference");
av = (AV *) SvRV (sv);
num_data = 0;
for (i = 0; i <= av_len (av); i++) {
SV **svp;
HV *hv;
svp = av_fetch (av, i, 0);
if (!svp || !cairo_perl_sv_is_hash_ref (*svp))
croak ("a Cairo::Path has to contain hash references");
hv = (HV *) SvRV (*svp);
svp = hv_fetch (hv, "type", 4, 0);
if (!svp || !cairo_perl_sv_is_defined (*svp))
croak ("hash references inside a Cairo::Path must have a 'type' key");
switch (cairo_path_data_type_from_sv (*svp)) {
case CAIRO_PATH_MOVE_TO:
case CAIRO_PATH_LINE_TO:
num_data += 2;
break;
case CAIRO_PATH_CURVE_TO:
num_data += 4;
break;
case CAIRO_PATH_CLOSE_PATH:
num_data += 1;
break;
}
}
path = cairo_perl_alloc_temp (sizeof (cairo_path_t));
path->num_data = num_data;
path->data = cairo_perl_alloc_temp (path->num_data * sizeof (cairo_path_data_t));
path->status = CAIRO_STATUS_SUCCESS;
data = path->data;
for (i = 0; i <= av_len (av); i++) {
SV **svp;
HV *hv;
AV *points;
svp = av_fetch (av, i, 0);
hv = (HV *) SvRV (*svp);
svp = hv_fetch (hv, "points", 6, 0);
if (!svp || !cairo_perl_sv_is_array_ref (*svp))
croak ("hash references inside a Cairo::Path must "
"contain a 'points' key which contains an array "
"reference of points");
points = (AV *) SvRV (*svp);
svp = hv_fetch (hv, "type", 4, 0);
fill_data_from_array (data, cairo_path_data_type_from_sv (*svp), points);
data += data->header.length;
}
return path;
}
SV *
newSVCairoPath (cairo_path_t * path)
{
return create_tied_av (path, "Cairo::Path");
}
cairo_path_t *
SvCairoPath (SV * sv)
{
cairo_path_t * path;
path = cairo_perl_mg_get (sv);
if (!path) {
path = path_from_array (sv);
}
return path;
}
/* ------------------------------------------------------------------------- */
static SV *
newSVCairoPathData (cairo_path_data_t * data)
{
return create_tied_hv (data, "Cairo::Path::Data");
}
static cairo_path_data_t *
SvCairoPathData (SV * sv)
{
return cairo_perl_mg_get (sv);
}
/* ------------------------------------------------------------------------- */
static SV *
newSVCairoPathPoints (cairo_path_data_t * data)
{
return create_tied_av (data, "Cairo::Path::Points");
}
static cairo_path_data_t *
SvCairoPathPoints (SV * sv)
{
return cairo_perl_mg_get (sv);
}
/* ------------------------------------------------------------------------- */
static SV *
newSVCairoPathPoint (cairo_path_data_t * data)
{
return create_tied_av (data, "Cairo::Path::Point");
}
static cairo_path_data_t *
SvCairoPathPoint (SV * sv)
{
return cairo_perl_mg_get (sv);
}
/* ------------------------------------------------------------------------- */
static IV
n_points (cairo_path_data_t * data)
{
switch (data->header.type) {
case CAIRO_PATH_MOVE_TO:
case CAIRO_PATH_LINE_TO:
return 1;
case CAIRO_PATH_CURVE_TO:
return 3;
case CAIRO_PATH_CLOSE_PATH:
return 0;
}
return -1;
}
/* ------------------------------------------------------------------------- */
MODULE = Cairo::Path PACKAGE = Cairo::Path
void DESTROY (SV * sv)
PREINIT:
cairo_path_t *path;
CODE:
path = SvCairoPath (sv);
if (path) {
#if PERL_REVISION <= 5 && PERL_VERSION <= 6
/* Unset mg_ptr to prevent perl 5.6.x from trying to free it again. */
MAGIC *mg = cairo_perl_mg_find (SvRV (sv), PERL_MAGIC_ext);
mg->mg_ptr = NULL;
#endif /* 5.6.x */
cairo_path_destroy (path);
}
IV FETCHSIZE (cairo_path_t * path)
PREINIT:
int i;
CODE:
RETVAL = 0;
for (i = 0; i < path->num_data; i += path->data[i].header.length)
RETVAL++;
OUTPUT:
RETVAL
SV * FETCH (cairo_path_t * path, IV index)
PREINIT:
int i, counter = 0;
CODE:
RETVAL = &PL_sv_undef;
for (i = 0; i < path->num_data; i += path->data[i].header.length) {
if (counter++ == index) {
cairo_path_data_t *data = &path->data[i];
RETVAL = newSVCairoPathData (data);
break;
}
}
OUTPUT:
RETVAL
# --------------------------------------------------------------------------- #
MODULE = Cairo::Path PACKAGE = Cairo::Path::Data
#if PERL_REVISION <= 5 && PERL_VERSION <= 6
void DESTROY (SV * sv)
CODE:
/* Unset mg_ptr to prevent perl 5.6.x from trying to free it. */
MAGIC *mg = cairo_perl_mg_find (SvRV (sv), PERL_MAGIC_ext);
if (mg)
mg->mg_ptr = NULL;
#endif /* 5.6.x */
SV * FETCH (SV * sv, const char * key)
PREINIT:
cairo_path_data_t * data;
CODE:
data = SvCairoPathData (sv);
if (strEQ (key, "type")) {
RETVAL = cairo_path_data_type_to_sv (data->header.type);
} else if (strEQ (key, "points")) {
RETVAL = newSVCairoPathPoints (data);
} else {
croak ("Unknown key '%s' for Cairo::Path::Data", key);
RETVAL = NULL;
}
OUTPUT:
RETVAL
SV * STORE (SV * sv, const char * key, SV * value)
PREINIT:
cairo_path_data_t * data;
CODE:
data = SvCairoPathData (sv);
if (strEQ (key, "points")) {
RETVAL = newSVCairoPathPoints (data);
fill_data_from_array (data, data->header.type, (AV *) SvRV (value));
} else {
croak ("Unhandled key '%s' for Cairo::Path::Data; "
"only changing 'points' is supported", key);
RETVAL = NULL;
}
OUTPUT:
RETVAL
bool EXISTS (sv, const char * key)
CODE:
if (strEQ (key, "type")) {
RETVAL = TRUE;
} else if (strEQ (key, "points")) {
RETVAL = TRUE;
} else {
RETVAL = FALSE;
}
OUTPUT:
RETVAL
const char * FIRSTKEY (sv)
CODE:
RETVAL = "type";
OUTPUT:
RETVAL
const char * NEXTKEY (sv, const char * lastkey)
CODE:
if (strEQ (lastkey, "type")) {
RETVAL = "points";
} else {
RETVAL = NULL;
}
OUTPUT:
RETVAL
# --------------------------------------------------------------------------- #
MODULE = Cairo::Path PACKAGE = Cairo::Path::Points
#if PERL_REVISION <= 5 && PERL_VERSION <= 6
void DESTROY (SV * sv)
CODE:
/* Unset mg_ptr to prevent perl 5.6.x from trying to free it. */
MAGIC *mg = cairo_perl_mg_find (SvRV (sv), PERL_MAGIC_ext);
if (mg)
mg->mg_ptr = NULL;
#endif /* 5.6.x */
IV FETCHSIZE (SV * sv)
PREINIT:
cairo_path_data_t * data;
CODE:
data = SvCairoPathPoints (sv);
RETVAL = n_points (data);
OUTPUT:
RETVAL
SV * FETCH (SV * sv, IV index)
PREINIT:
cairo_path_data_t * data;
CODE:
data = SvCairoPathPoints (sv);
if (index >= 0 && index < n_points (data)) {
RETVAL = newSVCairoPathPoint (&data[index + 1]);
} else {
RETVAL = &PL_sv_undef;
}
OUTPUT:
RETVAL
SV * STORE (SV * sv, IV index, SV * value)
PREINIT:
cairo_path_data_t * data;
CODE:
data = SvCairoPathPoints (sv);
if (index >= 0 && index < n_points (data)) {
cairo_path_data_t * point;
AV * av;
SV ** svp;
point = &data[index + 1];
RETVAL = newSVCairoPathPoint (point);
av = (AV *) SvRV (value);
if ((svp = av_fetch (av, 0, 0)))
point->point.x = SvNV (*svp);
if ((svp = av_fetch (av, 1, 0)))
point->point.y = SvNV (*svp);
} else {
RETVAL = &PL_sv_undef;
}
OUTPUT:
RETVAL
# --------------------------------------------------------------------------- #
MODULE = Cairo::Path PACKAGE = Cairo::Path::Point
#if PERL_REVISION <= 5 && PERL_VERSION <= 6
void DESTROY (SV * sv)
CODE:
/* Unset mg_ptr to prevent perl 5.6.x from trying to free it. */
MAGIC *mg = cairo_perl_mg_find (SvRV (sv), PERL_MAGIC_ext);
if (mg)
mg->mg_ptr = NULL;
#endif /* 5.6.x */
IV FETCHSIZE (sv)
CODE:
RETVAL = 2;
OUTPUT:
RETVAL
SV * FETCH (SV * sv, IV index)
PREINIT:
cairo_path_data_t * data;
CODE:
data = SvCairoPathPoint (sv);
switch (index) {
case 0:
RETVAL = newSVnv (data->point.x);
break;
case 1:
RETVAL = newSVnv (data->point.y);
break;
default:
RETVAL = &PL_sv_undef;
break;
}
OUTPUT:
RETVAL
SV * STORE (SV * sv, IV index, NV value)
PREINIT:
cairo_path_data_t * data;
CODE:
data = SvCairoPathPoint (sv);
switch (index) {
case 0:
RETVAL = newSVnv (data->point.x = value);
break;
case 1:
RETVAL = newSVnv (data->point.y = value);
break;
default:
RETVAL = &PL_sv_undef;
break;
}
OUTPUT:
RETVAL
Cairo-1.109/cairo-perl.h 000644 001750 000024 00000005521 11747045545 015237 0 ustar 00brian staff 000000 000000 /*
* Copyright (c) 2004-2005, 2012 by the cairo perl team (see the file README)
*
* Licensed under the LGPL, see LICENSE file for more information.
*
* $Id$
*
*/
#ifndef _CAIRO_PERL_H_
#define _CAIRO_PERL_H_
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include
#ifdef CAIRO_HAS_PNG_SURFACE
# include
#endif
#ifdef CAIRO_HAS_PS_SURFACE
# include
#endif
#ifdef CAIRO_HAS_PDF_SURFACE
# include
#endif
#ifdef CAIRO_HAS_SVG_SURFACE
# include
#endif
#if CAIRO_HAS_FT_FONT
# include
#endif
#include
/*
* standard object and struct handling
*/
void *cairo_object_from_sv (SV *sv, const char *package);
SV *cairo_object_to_sv (void *object, const char *package);
void *cairo_struct_from_sv (SV *sv, const char *package);
SV *cairo_struct_to_sv (void *object, const char *package);
/*
* custom struct handling
*/
SV * newSVCairoFontExtents (cairo_font_extents_t *extents);
SV * newSVCairoTextExtents (cairo_text_extents_t *extents);
SV * newSVCairoGlyph (cairo_glyph_t *glyph);
cairo_glyph_t * SvCairoGlyph (SV *sv);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 8, 0)
SV * newSVCairoTextCluster (cairo_text_cluster_t *cluster);
cairo_text_cluster_t * SvCairoTextCluster (SV *sv);
#endif
SV * newSVCairoPath (cairo_path_t *path);
cairo_path_t * SvCairoPath (SV *sv);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
#undef newSVCairoRectangle
#undef SvCairoRectangle
SV * newSVCairoRectangle (cairo_rectangle_t *rectangle);
cairo_rectangle_t * SvCairoRectangle (SV *sv);
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)
#undef newSVCairoRectangleInt
#undef SvCairoRectangleInt
SV * newSVCairoRectangleInt (cairo_rectangle_int_t *rectangle);
cairo_rectangle_int_t * SvCairoRectangleInt (SV *sv);
#endif
/*
* special treatment for surfaces
*/
SV * cairo_surface_to_sv (cairo_surface_t *surface);
#undef newSVCairoSurface
#undef newSVCairoSurface_noinc
#define newSVCairoSurface(object) (cairo_surface_to_sv (cairo_surface_reference (object)))
#define newSVCairoSurface_noinc(object) (cairo_surface_to_sv (object))
/*
* special treatment for patterns
*/
SV * cairo_pattern_to_sv (cairo_pattern_t *surface);
#undef newSVCairoPattern
#undef newSVCairoPattern_noinc
#define newSVCairoPattern(object) (cairo_pattern_to_sv (cairo_pattern_reference (object)))
#define newSVCairoPattern_noinc(object) (cairo_pattern_to_sv (object))
/*
* special treatment for font faces
*/
SV * cairo_font_face_to_sv (cairo_font_face_t *surface);
#undef newSVCairoFontFace
#undef newSVCairoFontFace_noinc
#define newSVCairoFontFace(object) (cairo_font_face_to_sv (cairo_font_face_reference (object)))
#define newSVCairoFontFace_noinc(object) (cairo_font_face_to_sv (object))
/*
* Type aliases for the typemap
*/
typedef char char_utf8;
#endif /* _CAIRO_PERL_H_ */
Cairo-1.109/CairoMatrix.xs 000644 001750 000024 00000006151 11664366475 015635 0 ustar 00brian staff 000000 000000 /*
* Copyright (c) 2004-2005 by the cairo perl team (see the file README)
*
* Licensed under the LGPL, see LICENSE file for more information.
*
* $Id$
*/
#include
cairo_matrix_t *
cairo_perl_copy_matrix (cairo_matrix_t *src)
{
cairo_matrix_t *dst;
New (0, dst, 1, cairo_matrix_t);
dst->xx = src->xx;
dst->xy = src->xy;
dst->x0 = src->x0;
dst->yx = src->yx;
dst->yy = src->yy;
dst->y0 = src->y0;
return dst;
}
MODULE = Cairo::Matrix PACKAGE = Cairo::Matrix PREFIX = cairo_matrix_
##void cairo_matrix_init (cairo_matrix_t *matrix, double xx, double yx, double xy, double yy, double x0, double y0);
cairo_matrix_t * cairo_matrix_init (class, double xx, double yx, double xy, double yy, double x0, double y0)
PREINIT:
cairo_matrix_t matrix;
CODE:
cairo_matrix_init (&matrix, xx, yx, xy, yy, x0, y0);
RETVAL = cairo_perl_copy_matrix (&matrix);
OUTPUT:
RETVAL
##void cairo_matrix_init_identity (cairo_matrix_t *matrix);
cairo_matrix_t * cairo_matrix_init_identity (class)
PREINIT:
cairo_matrix_t matrix;
CODE:
cairo_matrix_init_identity (&matrix);
RETVAL = cairo_perl_copy_matrix (&matrix);
OUTPUT:
RETVAL
##void cairo_matrix_init_translate (cairo_matrix_t *matrix, double tx, double ty);
cairo_matrix_t * cairo_matrix_init_translate (class, double tx, double ty)
PREINIT:
cairo_matrix_t matrix;
CODE:
cairo_matrix_init_translate (&matrix, tx, ty);
RETVAL = cairo_perl_copy_matrix (&matrix);
OUTPUT:
RETVAL
##void cairo_matrix_init_scale (cairo_matrix_t *matrix, double sx, double sy);
cairo_matrix_t * cairo_matrix_init_scale (class, double sx, double sy)
PREINIT:
cairo_matrix_t matrix;
CODE:
cairo_matrix_init_scale (&matrix, sx, sy);
RETVAL = cairo_perl_copy_matrix (&matrix);
OUTPUT:
RETVAL
##void cairo_matrix_init_rotate (cairo_matrix_t *matrix, double radians);
cairo_matrix_t * cairo_matrix_init_rotate (class, double radians)
PREINIT:
cairo_matrix_t matrix;
CODE:
cairo_matrix_init_rotate (&matrix, radians);
RETVAL = cairo_perl_copy_matrix (&matrix);
OUTPUT:
RETVAL
void cairo_matrix_translate (cairo_matrix_t * matrix, double tx, double ty);
void cairo_matrix_scale (cairo_matrix_t * matrix, double sx, double sy);
void cairo_matrix_rotate (cairo_matrix_t * matrix, double radians);
cairo_status_t cairo_matrix_invert (cairo_matrix_t * matrix);
##void cairo_matrix_multiply (cairo_matrix_t * result, const cairo_matrix_t * a, const cairo_matrix_t * b);
cairo_matrix_t * cairo_matrix_multiply (cairo_matrix_t * a, cairo_matrix_t * b)
PREINIT:
cairo_matrix_t matrix;
CODE:
cairo_matrix_multiply (&matrix, a, b);
RETVAL = cairo_perl_copy_matrix (&matrix);
OUTPUT:
RETVAL
##void cairo_matrix_transform_distance (cairo_matrix_t * matrix, double * dx, double * dy);
void cairo_matrix_transform_distance (cairo_matrix_t * matrix, IN_OUTLIST double dx, IN_OUTLIST double dy);
##void cairo_matrix_transform_point (cairo_matrix_t * matrix, double * x, double * y);
void cairo_matrix_transform_point (cairo_matrix_t * matrix, IN_OUTLIST double x, IN_OUTLIST double y);
void DESTROY (cairo_matrix_t * matrix)
CODE:
Safefree (matrix);
Cairo-1.109/ChangeLog.pre-git 000644 001750 000024 00000060462 11706204443 016143 0 ustar 00brian staff 000000 000000 === ChangeLog discontinued ===
With the move to git, we stop maintaining a separate ChangeLog and
rely on proper commit messages instead. Web view of changes:
.
2009-03-28 Torsten Schoenfeld
* NEWS
* README
* lib/Cairo.pm: Stable release 1.061.
2009-03-28 Torsten Schoenfeld
* Cairo.pm → lib/Cairo.pm (moved)
* MakeHelper.pm → inc/MakeHelper.pm (moved)
* MANIFEST
* Makefile.PL: Move the two modules into their own folders to make
it clear that the one is the real thing while the other is just
build helper code.
2009-03-28 Torsten Schoenfeld
* Cairo.xs (cairo_object_from_sv, cairo_struct_from_sv): Hush two
compiler warnings.
2009-03-28 Torsten Schoenfeld
* Cairo.pm: In the POD, use =item instead of =head4 for methods so
that not every single method shows up in a table of contents.
Also fix two other small POD glitches.
2009-03-28 Torsten Schoenfeld
* MANIFEST.SKIP: Update for SVN.
2009-03-28 Torsten Schoenfeld
* Makefile.PL: Use EU::MM's META_MERGE instead of EXTRA_META.
2008-10-26 Torsten Schoenfeld
* Makefile.PL: CAIRO_FONT_TYPE_QUARTZ was introduced in cairo 1.6,
not 1.4.
2008-10-05 Torsten Schoenfeld
* MakeHelper.pm: Use the correct enum type instead of int for the
enum converters.
2008-10-05 Torsten Schoenfeld
* Cairo.pm:
* Cairo.xs:
* CairoFont.xs:
* CairoFt.xs:
* CairoMatrix.xs:
* CairoPath.xs:
* CairoPattern.xs:
* CairoSurface.xs:
* MakeHelper.pm:
* Makefile.PL:
* cairo-perl-private.h:
* cairo-perl.h:
* cairo-perl.typemap:
* examples/simple.pl:
* t/Cairo.t:
* t/CairoFont.t:
* t/CairoFt.t:
* t/CairoMatrix.t:
* t/CairoPath.t:
* t/CairoPattern.t:
* t/CairoSurface.t: In preparation of the move to SVN, use the Id
keyword in place of Header.
2008-09-07 Torsten Schoenfeld
* Makefile.PL: When prompting for auto-installing dependencies,
default to 'no' so that automatic testers with CPANPLUS.pm don't
end up invoking CPAN.pm. (RT #38286)
2008-09-06 Torsten Schoenfeld
* README: Fix the dependency versions for EU::Depends and
EU::PkgConfig.
* Cairo.pm: Mention http://cairographics.org/manual/ in the API
documentation section. Fix a POD error.
* Makefile.PL: Support the enum value CAIRO_FONT_TYPE_QUARTZ. (RT
#34681)
2008-06-01 Torsten Schoenfeld
* t/CairoSurface.t: Cairo::PsSurface->create can under certain
conditions apparently return a surface that is not a PS surface.
Handle this gracefully. (RT #33871)
2008-04-19 Torsten Schoenfeld
* Cairo.pm
* NEWS: Stable release 1.060.
2008-04-19 Torsten Schoenfeld
* Cairo.pm: Add documentation for new API.
2008-03-22 Torsten Schoenfeld
* Makefile.PL: Trap exceptions thrown by EU::PkgConfig->find.
When one occurs, exit with status 0 to indicate to CPAN testers
that their system isn't supported.
2008-02-24 Torsten Schoenfeld
* Cairo.pm
* NEWS: Unstable release 1.053.
2008-02-24 Torsten Schoenfeld
* Cairo.pm
* Cairo.xs
* t/Cairo.t: Wrap cairo_has_current_point.
2008-02-12 Torsten Schoenfeld
* Cairo.pm
* NEWS: Unstable release 1.052.
2008-02-10 Torsten Schoenfeld
* Cairo.xs
* t/Cairo.t: Wrap cairo_path_extents.
* CairoSurface.xs
* t/CairoSurface.t: Wrap cairo_format_stride_for_width. Adapt to
API changes: cairo_surface_copy_page and cairo_surface_show_page
don't return cairo_status_t anymore.
* CairoPath.xs: Fix the tied interface for paths on perl 5.6,
whose magic support was slightly broken. Also cleanup the tie
code a bit.
2008-01-07 Torsten Schoenfeld
* Cairo.pm
* NEWS: Unstable release 1.051.
2008-01-07 Torsten Schoenfeld
* Cairo.pm
* CairoSurface.xs
* t/CairoSurface.t: Wrap cairo_surface_copy_page and
cairo_surface_show_page.
* Cairo.pm
* Makefile.PL
* CairoSurface.xs
* t/CairoSurface.t: Wrap cairo_ps_surface_restrict_to_level,
cairo_ps_get_levels, and cairo_ps_level_to_string.
* Cairo.pm
* CairoSurface.xs
* t/CairoSurface.t: Wrap cairo_ps_surface_set_eps and
cairo_ps_surface_get_eps.
2007-12-29 Torsten Schoenfeld
* Cairo.xs
* CairoFont.xs
* CairoMatrix.xs
* CairoSurface.xs: Use perl's New*/Safefree facilities instead of
calloc/malloc/free as the latter aren't safe on some platforms,
notably Win32. Patch by T.J. Ferraro.
* t/CairoSurface.t: Mark the isa_ok test for PDF surfaces returned
by create_similar() as TODO, since the returned surface's type is
not reliable at this point.
2007-11-20 Torsten Schoenfeld
* Cairo.pm
* NEWS: Unstable release 1.050.
2007-11-20 Torsten Schoenfeld
* Cairo.pm: Add entries for the various surfaces to the API
listing.
* Makefile.PL: Update the list of exported symbols. (Reported by
spicy jack)
2007-10-24 Torsten Schoenfeld
* t/CairoFont.t: Really don't use the hash-ref variant of the
constant pragma this time.
* Cairo.pm
* Cairo.xs
* CairoFt.xs
* Makefile.PL
* cairo-perl.h
* cairo-perl.typemap
* examples/freetype-font.pl
* t/CairoFt.t: Add support for part of cairo's FreeType
integration API. Currently, that's just
Cairo::FtFontFace::create, which lets you create a cairo font face
from a FreeType font face.
2007-10-18 Torsten Schoenfeld
* t/Cairo.t
* t/CairoPattern.t: When Test::Number::Delta is not available,
skip the relevant tests instead of faking passes. (Suggested by
Aristotle Pagaltzis)
2007-10-14 Torsten Schoenfeld
* t/Cairo.t
* t/CairoFont.t
* t/CairoPath.t
* t/CairoPattern.t
* t/CairoSurface.t: Don't use the hash-ref variant of the constant
pragma. It's not supported by the version that ships with perl
5.6.
2007-10-14 Torsten Schoenfeld
* Cairo.pm
* NEWS
* README: Release 1.043.
2007-10-13 Torsten Schoenfeld
* Makefile.PL: Use BEGIN { require 5.006; } instead of require
v5.6.0. Make missing Test::Number::Delta non-fatal; add it to the
build_requires META.yml field.
* t/Cairo.t
* t/CairoPattern.t: Cope with Test::Number::Delta being
unavailable.
2007-10-07 Torsten Schoenfeld
* Makefile.PL: Make EU::MM output configure_requires and no_index
information when generating META.yml.
* t/CairoSurface.t (PNG surface tests): Since exceptions are
actually propagated now, throw the same kind of exception we test
for.
2007-10-06 Torsten Schoenfeld
* Makefile.PL: Require perl >= 5.6.0 for some features we use,
like `our´.
2007-09-30 tsch
* ppport.h
* Cairo.xs
* CairoPath.xs
* CairoPattern.xs
* CairoSurface.xs
* MANIFEST
* cairo-perl-private.h
* cairo-perl.h: Add and use the portability header ppport.h from
Devel::PPPort to hopefully fix compilation on older perls.
2007-09-27 tsch
* Cairo.pm
* NEWS
* README: Stable release 1.042.
2007-09-27 tsch
* Makefile.PL: Make missing prerequisites fatal.
2007-09-09 tsch
* cairo-perl.typemap: Add const char * for backwards
compatibility.
2007-08-13 tsch
* doctypes: Add missing type names.
2007-05-27 tsch
* Cairo.pm, NEWS, README: Stable release 1.041.
2007-05-27 tsch
* t/CairoSurface.t: Use proper version checks to decide when to
skip the create_for_stream tests.
2007-05-13 tsch
* Makefile.PL, README, t/Cairo.t, t/CairoPattern.t: Use
Test::Number::Delta to make floating point number comparisons more
reliable.
2007-05-10 tsch
* Cairo.pm, NEWS, README: Stable release 1.040.
2007-05-10 tsch
* t/CairoSurface.t: For now, skip tests that make cairo crash.
2007-05-06 tsch
* Cairo.pm: Document new API. Mark functions that were added
after cairo 1.0.
2007-05-06 tsch
* Cairo.xs
* CairoPattern.xs
* Makefile.PL
* cairo-perl.h
* t/Cairo.t
* t/CairoPattern.t: Use 1.4.0 in version checks.
* Cairo.xs: If CAIRO_PERL_DEBUG is true, call
cairo_debug_reset_static_data at exit.
2007-03-17 tsch
* Cairo.xs
* t/Cairo.t: Wrap cairo_get_scaled_font.
* CairoSurface.xs
* t/CairoSurface.t: Re-add the binding for cairo_surface_finish.
It was orignally removed because its effect can also be achieved
by destroying the surface or letting it go out of scope. But
Oleksandr Alex Protasenko convinced me that it's still a good idea
to have it anyway, mainly for paginated surfaces like PDF and PS
which defer rendering as long as they can. With $surf->finish you
can more clearly express what you're intending to do than with
$surf = undef.
* examples/png-streams.pl: Fix indention.
2007-01-21 tsch
* Cairo.pm, NEWS, README: Unstable release 1.031.
2007-01-21 tsch
* Cairo.xs: Track upstream API change: cairo_get_dash_count
returns the count directly; cairo_get_dash_count and
cairo_get_dash don't return a status anymore.
2007-01-18 tsch
* t/Cairo.t, Cairo.xs: Track upstream API improvement:
cairo_copy_clip_rectangles -> cairo_copy_clip_rectangle_list.
2007-01-05 tsch
* t/CairoSurface.t: Fix an endianness problem.
2006-12-30 tsch
* MakeHelper.pm: Fix the valid-value lists in enum error messages.
2006-12-28 tsch
* Cairo.pm, NEWS, README: Unstable release 1.030.
2006-12-28 tsch
* Cairo.xs, cairo-perl.h, t/Cairo.t: Wrap and test
cairo_copy_clip_rectangles and cairo_clip_extents.
2006-11-23 tsch
* CairoSurface.xs, t/CairoSurface.t: Make
Cairo::ImageSurface::get_data usable by specifying the buffer
length.
* MANIFEST, Makefile.PL, doctypes: Describe our types.
* NEWS: Merge from stable-1-0.
2006-11-09 tsch
* Cairo.xs, cairo-perl-private.h: Export cairo_perl_alloc_temp
privately.
* Cairo.xs: Remove the DOUBLES_ macros and inline them. They were
used only in one place.
* Cairo.xs, t/Cairo.t: Wrap cairo_get_dash.
* CairoPattern.xs, cairo-perl-private.h, t/CairoPattern.t: Wrap
cairo_pattern_get_rgba, cairo_pattern_get_surface,
cairo_pattern_get_color_stop_rgba, cairo_pattern_get_points, and
cairo_pattern_get_circles.
* Makefile.PL: Support new cairo_status_t values.
2006-11-09 tsch
* Cairo.pm, NEWS, README: Stable release 1.02.
2006-11-09 tsch
* MakeHelper.pm, CairoSurface.t: When comparing enum values, look
at length+1, not just length, bytes to discern string pairs like
'color' and 'color-alpha'. Duh! Many thanks to Martijn van Beers
for finding this bug.
2006-09-24 tsch
* Cairo.pm, NEWS: Stable release 1.01.
2006-09-24 tsch
* t/CairoSurface.t: Skip the create_for_stream test for ps and pdf
surfaces if cairo < 1.2.0. Earlier versions didn't handle errors
correctly and thus caused too many tests. Also partly revert the
previous change and instead do a conditional type check on
surfaces create with create_similar.
2006-09-24 tsch
* t/CairoSurface.t: Don't check the specific type of similar
surfaces created from PS and PDF surfaces; it's not reliable.
* xs/CairoSurface.xs: Cosmetical changes.
2006-09-04 tsch
* Cairo.pm, NEWS, README: Stable release 1.00.
2006-08-27 tsch
* Makefile.PL: Make EU::MM export our symbols on Win32.
2006-08-20 tsch
* MakeHelper.pm: Revert the last commit which used real enum types
instead of int; it broke compilation. Also alter the way unknown
enum types are dealt with: don't declare and implement stub
converters, just omit them. Still declare typemaps for them
though, to make xsubpp happy.
2006-08-20 tsch
* MakeHelper.pm: Add the infrastructure necessary to support
protecting the enum related things with #ifdef, if needed. Also
use the real enum types for the enum converters, instead of just
int.
2006-08-15 tsch
* Cairo.pm, MANIFEST, NEWS, README: Beta release 0.92.
2006-08-13 tsch
* CairoSurface.xs (read_func_marshaller): Use POPs, SvPV, and
sv_len instead of POPpx to avoid problems on perl 5.8.8 reported
by Joe Smith and Alexey Tourbin.
2006-08-11 tsch
* examples/png-streams.pl: New example that demonstrates how to
use the PNG stream functions.
* t/CairoSurface.t: Whitespace fix.
2006-08-11 tsch
* CairoSurface.xs: Patch from Yaakov S puts version guards around
a few PDF and PS functions that appeared in 1.2.0.
* t/CairoSurface.t: Do the same for the corresponding tests.
2006-08-10 tsch
* Cairo.pm, NEWS, README: Beta release 0.91.
2006-08-10 tsch
* Cairo.xs, CairoFont.xs, CairoPattern.xs, CairoSurface.xs,
MakeHelper.pm, Makefile.PL, cairo-perl-private.h, t/Cairo.t,
t/CairoFont.t, t/CairoPattern.t, t/CairoSurface.t: Make it
possible to compile and run the bindings against cairo 1.0.x. Use
a package lookup table for patterns and surfaces to work around
the lack of type accessors. Add version guards around things that
were introduced in 1.2.0.
* CairoSurface.xs: Use OUTLIST for
cairo_surface_get_device_offset.
* CairoPattern.xs, CairoSurface.xs, cairo-perl-private.h: Rename
cair_perl_set_isa to cairo_perl_set_isa. Doh!
* t/CairoSurface.t: Explicitly clear the image surface on cairo
1.0.x before writing it out since 1.0.x doesn't do it for us. Use
lexical surface variables to make sure they get destroyed before
execution ends which in turn makes sure all tests inside callbacks
are run before Test::More checks if reality matches the test plan.
2006-07-15 tsch
* Cairo.pm, NEWS, README: Beta release 0.90.
2006-07-15 tsch
* Cairo.pm: Update existing, add new documentation.
* TODO: Update.
2006-07-15 tsch
* Cairo.xs: Remove Cairo::HAS_XLIB_SURFACE and HAS_FT_FONT.
* Cairo.pm, Cairo.xs, CairoPattern.xs, CairoSurface.xs,
cairo-perl-private.h: Add cairo_perl_set_isa and use it for
surfaces and patterns.
* CairoSurface.xs, Makefile.PL, cairo-perl.h, t/CairoSurface.t:
Add support for svg surfaces if available.
* t/CairoSurface.t: Remove TODO block and revert workaround
related to the weird unknown surface types. It's been fixed
upstream: https://bugs.freedesktop.org/show_bug.cgi?id=7322
2006/07/02 tsch
* Makefile.PL: Require cairo 1.2.0. Add CAIRO_FORMAT_RGB16_565.
* Cairo.pm, CairoFont.xs: Cosmetical changes.
* Cairo.xs: Add Cairo::VERSION and Cairo::VERSION_ENCODE.
* t/CairoSurface.t: Shuffle a few tests around to avoid some
strange singularities.
2006/06/15 tsch
* Cairo.pm, MANIFEST, NEWS, README: Release 0.04.
2006/06/15 tsch
* t/CairoSurface.t: Wrap two tests that recently started failing
in TODO blocks.
2006/06/14 tsch
* Makefile.PL: Require cairo >= 1.1.8.
* CairoSurface.xs, t/CairoSurface.t: Wrap and test
cairo_surface_set_fallback_resolution,
cairo_image_surface_get_data, cairo_image_surface_get_format, and
cairo_image_surface_get_stride. Remove the wrappers and tests for
cairo_pdf_surface_set_dpi and cairo_ps_surface_set_dpi.
* t/CairoSurface.t: Test Cairo::ImageSurface::get_width and
get_height.
2006/06/03 tsch
* Cairo.pm: Document Cairo::get_group_target, Cairo::new_sub_path,
Cairo::Pattern::get_type, Cairo::set_scaled_font, Cairo::version,
and Cairo::version_string.
* t/Cairo.t, Cairo.xs: Allow Cairo::version[_string] to be called
as a function and as a class method.
* CairoPattern.xs, CairoSurface.xs, t/CairoSurface.t, Makefile.PL,
examples/simple.pl, examples/png/caps_joins.pl,
examples/png/hering.pl: Whitespace fixes.
* t/CairoSurface.t, CairoSurface.xs: Wrap
cairo_surface_get_content.
* MakeHelper.pm: Don't add a linebreak to croaks so perl prints
line information.
* Makefile.PL: Require cairo 1.1.7.
* examples/png/README, examples/png/bevels.pl,
examples/png/spline-pipeline.pl, examples/png/text-rotate.pl,
examples/png/text.pl: New example ports.
2006/05/14 tsch
* t/CairoSurface.t, CairoSurface.xs: Remove
Cairo::Surface::finish; it's memory management related and not
needed, as far as I can tell. Scream if you used it.
* t/CairoSurface.t, CairoSurface.xs: Bind and test
cairo_surface_write_to_png_stream,
cairo_image_surface_create_from_png_stream,
cairo_pdf_surface_create_for_stream, and
cairo_ps_surface_create_for_stream.
* CairoSurface.xs: Don't leak cairo_surface_create_similar's
return value.
* cairo-perl-private.h: Remove CAIRO_PERL_UNUSED.
* cairo-perl-private.h, Cairo.xs, CairoFont.xs, CairoMatrix.xs,
CairoPattern.xs: Rename pcairo_copy_matrix to
cairo_perl_copy_matrix.
* TODO: Update.
2006/05/07 tsch
* .cvsignore, MANIFEST.SKIP: Update.
* Cairo.pm: Update copyright notice.
* MANIFEST, cairo-perl-private.h: Add a private header file for
non-public declarations that are used in more than one place.
* MakeHelper.pm: Improve the enum converters to produce more useful
error messages.
* Makefile.PL: Incorporate a slightly modified patch from Christopher
Oezbek to prompt the user if he wants to install EU::Depends and
EU::PkgConfig if they can't be found. Require cairo >= 1.1.6. Update
and rearrange enums.
* cairo-perl.h, Cairo.xs: Move CAIRO_PERL_CALL_BOOT to Cairo.xs.
* cairo-perl.h, CairoSurface.xs, CairoPattern.xs, Makefile.PL: Use
cairo_surface_get_type and cairo_pattern_get_type to redo the sub-type
handling for surfaces and patterns.
* cairo-perl-private.h, Cairo.xs, CairoMatrix.xs, CairoPattern.xs: Add
pcairo_copy_matrix and use it all over the place to make matrix handling
more robust.
* Cairo.xs, t/Cairo.t: Wrap cairo_version, cairo_version_string,
cairo_push_group, cairo_push_group_with_content, cairo_pop_group,
cairo_pop_group_to_source, cairo_new_sub_path, cairo_set_scaled_font,
and cairo_get_group_target.
* CairoFont.xs, t/CairoFont.t: Wrap cairo_font_face_get_type,
cairo_scaled_font_get_type, cairo_scaled_font_text_extents,
cairo_scaled_font_get_font_face, cairo_scaled_font_get_font_matrix,
cairo_scaled_font_get_ctm, and cairo_scaled_font_get_font_options.
* CairoPattern.xs, t/CairoPattern.t: Wrap cairo_pattern_get_type.
* CairoSurface.xs, t/CairoSurface.t: Wrap
cairo_surface_get_device_offset, cairo_surface_get_type,
cairo_pdf_surface_set_size, cairo_ps_surface_set_dpi,
cairo_ps_surface_set_size, cairo_ps_surface_dsc_comment,
cairo_ps_surface_dsc_begin_setup, and cairo_ps_surface_dsc_begin_setup.
2006/01/29 tsch
* Cairo.pm, NEWS, README: Release 0.03.
2006/01/29 tsch
* Cairo.pm, CairoPattern.xs, Makefile.PL, cairo-perl.h,
t/CairoPattern.t: Add Cairo::SolidPattern::create_rgb and
create_rgba.
2006/01/28 tsch
* Cairo.pm: Add documentation for Cairo::Context, paths, patterns,
transformations, and text.
2006/01/08 tsch
* Cairo.pm: Make DynaLoader export all our symbols.
* Cairo.xs, MakeHelper.pm, Makefile.PL, cairo-perl.h: Revamp the
type conversion API. Instead of implementing everything in the
typemap, we now have macros like newSVCairoPattern and
SvCairoPattern. These get exported, so other modules can make use
of them.
* cairo-perl.h: Remove the DBG macro.
* cairo-perl.typemap: Use T_UV instead of T_IV for cairo_bool_t.
2005/09/01 tsch
* Cairo.pm, MANIFEST, Makefile.PL, NEWS, README: Release 0.02.
Require cairo 1.0.0.
2005/08/31 tsch
* MakeHelper.pm, Makefile.PL: Surround our _noinc typedefs for the
PS and PDF backends with appropriate ifdefs to fix compilation
when these backends were not installed with cairo.
2005/08/18 tsch
* Cairo.pm: Fix incorrect package line that read GStreamer instead
of Cairo.
2005/08/15 tsch
* Cairo.pm, README: Release 0.01. Also add stub documentation.
* MANIFEST.SKIP: Remove CairoEnums.xs.
* Makefile.PL: Add ABSTRACT_FROM to the WriteMakefile call.
* TODO: Update to reflect the present situation.
2005/08/10 tsch
* t/Cairo.t, Cairo.xs: Bind cairo_set_antialias and
cairo_get_antialias.
* t/CairoSurface.t, CairoSurface.xs: Bind cairo_surface_flush,
cairo_surface_mark_dirty, cairo_surface_mark_dirty_rectangle.
* MANIFEST, META.yml: Remove META.yml; let EU::MakeMaker generate
it on "make dist".
* Makefile.PL: Require cairo 0.9.0. Add our prerequisites to the
WriteMakefile call so that they appear in the generated META.yml.
Support CAIRO_STATUS_FILE_NOT_FOUND.
2005/07/29 tsch
* t/Cairo.t, xs/Cairo.xs: Wrap cairo_get_font_options.
* t/CairoFont.t, xs/CairoFont.xs: Wrap cairo_font_face_status,
cairo_scaled_font_status, cairo_font_options_*. Update
cairo_scaled_font_create.
* t/CairoSurface.t, CairoSurface.xs: Wrap cairo_surface_status,
cairo_surface_get_font_options.
* Makefile.PL: Wrap the new cairo_font_options_t stuff.
* Makefile.PL: Require cairo 0.6.0. Add new and update the old
enums. Install all files necessary for other modules to use
Cairo.
* cairo-perl.typemap: Add a cairo_bool_t typemap.
2005/07/12 tsch
* Cairo.pm, Cairo.xs, t/Cairo.t: Replace the %backends hash with
Cairo::HAS_PS_SURFACE, HAS_PDF_SURFACE, HAS_XLIB_SURFACE,
HAS_FT_FONT and HAS_PNG_FUNCTIONS.
* Cairo.pm, CairoPattern.xs, CairoSurface.xs, Makefile.PL:
Implement the pattern and surface hierarchy suggested by the
language bindings guidelines.
* Cairo.xs: Use Cairo::Context for the namespace of cairo_t,
instead of just Cairo, as suggested by the guidelines.
* Cairo.xs, CairoFont.xs, CairoMatrix.xs, CairoPattern.xs,
CairoSurface.xs, cairo-perl.h: Add new, remove old API. Shuffle
some things around.
* Cairo.xs: Convert font and text extents and glyphs to and from
native Perl data structures.
* Cairo.xs, cairo-perl.h, cairo-perl.typemap: Remove everything
that cannot be used from Perl, like the XLib and Glitz stuff.
* CairoPath.xs, t/CairoPath.t: Add support for cairo_path_t,
including a nice tied interface that lets you iterate over paths
as if they were normal array references.
* MakeHelper.pm: Extend the typemap generator to support "const"
and "_noinc" types. Change the enum handling to use the Glib
convention, i.e. lowercase and hyphen instead of underscore.
* Makefile.PL, README: Use ExtUtils::Depends.
* examples/simple.pl, examples/png/caps_join.pl,
examples/png/hering.pl, examples/png/outline.pl,
examples/png/spiral.pl, examples/png/splines_tolerance.pl,
examples/png/stars.pl: Update the examples to make them work again
after all those API changes.
* t/Cairo.t, t/CairoFont.t, CairoMatrix.t, CairoPattern.t,
CairoSurface.t: Redo and/or expand the whole test suite.
2005/02/06 11:18 (-0500) rwmcfa1
* CairoSurface.xs: fixed a bug in wrapping of cairo_surface_xlib_create
where the return value wasn't being caught in RETVAL. thank you -Wall -W
* cairo-perl.h: wrapped new includes (prev log msg) in #ifdef HAS's so
that we can build on systems where no all backends are supported. XS
code already supports this.
2005-01-20 Carl Worth
* cairo-perl.h: Track split-up of cairo.h.
2004/11/28 13:20 (-0500) rwmcfa1
* Makefile.PL, MakeHelper.pm: initial import of MakeHelper, mess of
code moved out of Makefile.PL into it. beginning of cleaning all that
up. File::Spec now used.
* examples/png/*: initial import of port of cairo-demo/png examples,
except text.
* META.yml: unknown version
* MANIFEST, MANIFEST.SKIP: updates
2004/11/11 22:10 (-0500) rwmcfa1
* t/CairoMatrix.t, t/CairoPattern.t, t/CairoSurface.t: initial import,
95% complete tests
* Cairo.xs, CairoMatrix.xs, CairoSurface.xs, CairoPattern.xs: no more
new's, not really a good idea.
* CairoFont.xs: all disabled for now
* CairoMatrix.xs: copy, multiply, and transforms fixed while doing
tests
* CairoPattern.xs: get_matrix fixed whlie doing tests
* CairoSurface.xs: cleaned up the namespace problems herein. fixed
several output funcs.
* MANIFEST: added TODO and new tests.
* MANIFEST.SKIP: skip CairoEnums.xs
* t/Cairo.t: no new test, change Surface stuff due to namespace above
2004/11/10 21:08 (-0500) rwmcfa1
* TODO: initial import
* Cairo.pm, Cairo.xs: added %backends facility
* Cario.xs, CairoSurface.xs: stuff moved out of Cairo.xs that belonged
here
* Cairo.xs: fixed some OUTLIST stuff (IN_OUTLIST.) cairo_current_matrix
fixed.
* CairoPattern.xs: added class param to create_for_surface
* Makefile.PL: seperated structs out of objects. add refs to object
typemaps OUTPUT sections. don't return full strings for OUTPUT enum
types.
* cairo-perl.h: don't need stdio.h
* t/Cairo.t: test most all of cairo type. 90% done.
2004/11/08 20:44 (-0500) rwmcfa1
* Cairo.xs, CairoMatrix.xs, CairoPattern.xs, CairoSurface.xs: all of
the create functions have been cleaned up/fixed. debug prints removed.
create's alised to new's where appropriate.
* MANIFEST, MANIFEST.SKIP: ChangeLog added. build and CVS skipped
* Makefile.PL, cairo-perl.h, Cairo.xs: new (write_)boot code added,
in progress. use build dir for most of autogen'd stuff
Cairo-1.109/CairoPattern.xs 000644 001750 000024 00000020776 11664366475 016017 0 ustar 00brian staff 000000 000000 /*
* Copyright (c) 2004-2005 by the cairo perl team (see the file README)
*
* Licensed under the LGPL, see LICENSE file for more information.
*
* $Id$
*/
#include
#include
#include "ppport.h"
static const char *
get_package (cairo_pattern_t *pattern)
{
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_pattern_type_t type;
const char *package;
type = cairo_pattern_get_type (pattern);
switch (type) {
case CAIRO_PATTERN_TYPE_SOLID:
package = "Cairo::SolidPattern";
break;
case CAIRO_PATTERN_TYPE_SURFACE:
package = "Cairo::SurfacePattern";
break;
case CAIRO_PATTERN_TYPE_LINEAR:
package = "Cairo::LinearGradient";
break;
case CAIRO_PATTERN_TYPE_RADIAL:
package = "Cairo::RadialGradient";
break;
default:
warn ("unknown pattern type %d encountered", type);
package = "Cairo::Pattern";
break;
}
return package;
#else
const char *package = cairo_perl_package_table_lookup (pattern);
return package ? package : "Cairo::Pattern";
#endif
}
SV *
cairo_pattern_to_sv (cairo_pattern_t *pattern)
{
SV *sv = newSV (0);
sv_setref_pv(sv, get_package (pattern), pattern);
return sv;
}
/* ------------------------------------------------------------------------- */
MODULE = Cairo::Pattern PACKAGE = Cairo::Pattern PREFIX = cairo_pattern_
void DESTROY (cairo_pattern_t * pattern);
CODE:
cairo_pattern_destroy (pattern);
void cairo_pattern_set_matrix (cairo_pattern_t * pattern, cairo_matrix_t * matrix);
## void cairo_pattern_get_matrix (cairo_pattern_t * pattern, cairo_matrix_t * matrix);
cairo_matrix_t * cairo_pattern_get_matrix (cairo_pattern_t * pattern);
PREINIT:
cairo_matrix_t matrix;
CODE:
cairo_pattern_get_matrix (pattern, &matrix);
RETVAL = cairo_perl_copy_matrix (&matrix);
OUTPUT:
RETVAL
cairo_status_t cairo_pattern_status (cairo_pattern_t *pattern);
void cairo_pattern_set_extend (cairo_pattern_t * pattern, cairo_extend_t extend);
void cairo_pattern_set_filter (cairo_pattern_t * pattern, cairo_filter_t filter);
cairo_filter_t cairo_pattern_get_filter (cairo_pattern_t * pattern);
cairo_extend_t cairo_pattern_get_extend (cairo_pattern_t * pattern);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_pattern_type_t cairo_pattern_get_type (cairo_pattern_t *pattern);
#endif
# --------------------------------------------------------------------------- #
MODULE = Cairo::Pattern PACKAGE = Cairo::SolidPattern PREFIX = cairo_pattern_
BOOT:
cairo_perl_set_isa ("Cairo::SolidPattern", "Cairo::Pattern");
# cairo_pattern_t* cairo_pattern_create_rgb (double red, double green, double blue);
cairo_pattern_t_noinc * cairo_pattern_create_rgb (class, double red, double green, double blue)
C_ARGS:
red, green, blue
POSTCALL:
#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_perl_package_table_insert (RETVAL, "Cairo::SolidPattern");
#endif
# cairo_pattern_t* cairo_pattern_create_rgba (double red, double green, double blue, double alpha);
cairo_pattern_t_noinc * cairo_pattern_create_rgba (class, double red, double green, double blue, double alpha)
C_ARGS:
red, green, blue, alpha
POSTCALL:
#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_perl_package_table_insert (RETVAL, "Cairo::SolidPattern");
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
## cairo_status_t cairo_pattern_get_rgba (cairo_pattern_t *pattern, double *red, double *green, double *blue, double *alpha);
void cairo_pattern_get_rgba (cairo_pattern_t *pattern)
PREINIT:
cairo_status_t status;
double red, green, blue, alpha;
PPCODE:
status = cairo_pattern_get_rgba (pattern, &red, &green, &blue, &alpha);
CAIRO_PERL_CHECK_STATUS (status);
EXTEND (sp, 4);
PUSHs (sv_2mortal (newSVnv (red)));
PUSHs (sv_2mortal (newSVnv (green)));
PUSHs (sv_2mortal (newSVnv (blue)));
PUSHs (sv_2mortal (newSVnv (alpha)));
#endif
# --------------------------------------------------------------------------- #
MODULE = Cairo::Pattern PACKAGE = Cairo::SurfacePattern PREFIX = cairo_pattern_
BOOT:
cairo_perl_set_isa ("Cairo::SurfacePattern", "Cairo::Pattern");
cairo_pattern_t_noinc * create (class, cairo_surface_t * surface);
CODE:
RETVAL = cairo_pattern_create_for_surface (surface);
#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_perl_package_table_insert (RETVAL, "Cairo::SurfacePattern");
#endif
OUTPUT:
RETVAL
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
## cairo_status_t cairo_pattern_get_surface (cairo_pattern_t *pattern, cairo_surface_t **surface);
cairo_surface_t * cairo_pattern_get_surface (cairo_pattern_t *pattern)
PREINIT:
cairo_status_t status;
CODE:
status = cairo_pattern_get_surface (pattern, &RETVAL);
CAIRO_PERL_CHECK_STATUS (status);
OUTPUT:
RETVAL
#endif
# --------------------------------------------------------------------------- #
MODULE = Cairo::Pattern PACKAGE = Cairo::Gradient PREFIX = cairo_pattern_
BOOT:
cairo_perl_set_isa ("Cairo::Gradient", "Cairo::Pattern");
void cairo_pattern_add_color_stop_rgb (cairo_pattern_t *pattern, double offset, double red, double green, double blue);
void cairo_pattern_add_color_stop_rgba (cairo_pattern_t *pattern, double offset, double red, double green, double blue, double alpha);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
## cairo_status_t cairo_pattern_get_color_stop_count (cairo_pattern_t *pattern, int *count);
## cairo_status_t cairo_pattern_get_color_stop_rgba (cairo_pattern_t *pattern, int index, double *offset, double *red, double *green, double *blue, double *alpha);
void cairo_pattern_get_color_stops (cairo_pattern_t *pattern)
PREINIT:
cairo_status_t status;
int count, i;
double offset, red, green, blue, alpha;
PPCODE:
status = cairo_pattern_get_color_stop_count (pattern, &count);
CAIRO_PERL_CHECK_STATUS (status);
EXTEND (sp, count);
for (i = 0; i < count; i++) {
AV *av;
status = cairo_pattern_get_color_stop_rgba (pattern, i, &offset, &red, &green, &blue, &alpha);
CAIRO_PERL_CHECK_STATUS (status);
av = newAV ();
av_push (av, newSVnv (offset));
av_push (av, newSVnv (red));
av_push (av, newSVnv (green));
av_push (av, newSVnv (blue));
av_push (av, newSVnv (alpha));
PUSHs (sv_2mortal (newRV_noinc ((SV *) av)));
}
#endif
# --------------------------------------------------------------------------- #
MODULE = Cairo::Pattern PACKAGE = Cairo::LinearGradient PREFIX = cairo_pattern_
BOOT:
cairo_perl_set_isa ("Cairo::LinearGradient", "Cairo::Gradient");
cairo_pattern_t_noinc * create (class, double x0, double y0, double x1, double y1);
CODE:
RETVAL = cairo_pattern_create_linear (x0, y0, x1, y1);
#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_perl_package_table_insert (RETVAL, "Cairo::LinearGradient");
#endif
OUTPUT:
RETVAL
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
## cairo_status_t cairo_pattern_get_linear_points (cairo_pattern_t *pattern, double *x0, double *y0, double *x1, double *y1);
void cairo_pattern_get_points (cairo_pattern_t *pattern)
PREINIT:
cairo_status_t status;
double x0, y0, x1, y1;
PPCODE:
status = cairo_pattern_get_linear_points (pattern, &x0, &y0, &x1, &y1);
CAIRO_PERL_CHECK_STATUS (status);
EXTEND (sp, 4);
PUSHs (sv_2mortal (newSVnv (x0)));
PUSHs (sv_2mortal (newSVnv (y0)));
PUSHs (sv_2mortal (newSVnv (x1)));
PUSHs (sv_2mortal (newSVnv (y1)));
#endif
# --------------------------------------------------------------------------- #
MODULE = Cairo::Pattern PACKAGE = Cairo::RadialGradient PREFIX = cairo_pattern_
BOOT:
cairo_perl_set_isa ("Cairo::RadialGradient", "Cairo::Gradient");
cairo_pattern_t_noinc * create (class, double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
CODE:
RETVAL = cairo_pattern_create_radial (cx0, cy0, radius0, cx1, cy1, radius1);
#if CAIRO_VERSION < CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_perl_package_table_insert (RETVAL, "Cairo::RadialGradient");
#endif
OUTPUT:
RETVAL
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
## cairo_status_t cairo_pattern_get_radial_circles (cairo_pattern_t *pattern, double *x0, double *y0, double *r0, double *x1, double *y1, double *r1)
void cairo_pattern_get_circles (cairo_pattern_t *pattern)
PREINIT:
cairo_status_t status;
double x0, y0, r0, x1, y1, r1;
PPCODE:
status = cairo_pattern_get_radial_circles (pattern, &x0, &y0, &r0, &x1, &y1, &r1);
CAIRO_PERL_CHECK_STATUS (status);
EXTEND (sp, 6);
PUSHs (sv_2mortal (newSVnv (x0)));
PUSHs (sv_2mortal (newSVnv (y0)));
PUSHs (sv_2mortal (newSVnv (r0)));
PUSHs (sv_2mortal (newSVnv (x1)));
PUSHs (sv_2mortal (newSVnv (y1)));
PUSHs (sv_2mortal (newSVnv (r1)));
#endif
Cairo-1.109/META.json 000644 001750 000024 00000003525 14001743452 014440 0 ustar 00brian staff 000000 000000 {
"abstract" : "Perl interface to the cairo 2d vector graphics library",
"author" : [
"unknown",
"Cairo Perl Team "
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010",
"license" : [
"unknown",
"lgpl_2_1"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : 2
},
"name" : "Cairo",
"no_index" : {
"directory" : [
"t",
"inc"
],
"file" : [
"inc/MakeHelper.pm"
]
},
"prereqs" : {
"build" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"configure" : {
"requires" : {
"ExtUtils::Depends" : "0.2",
"ExtUtils::MakeMaker" : "0",
"ExtUtils::PkgConfig" : "1"
}
},
"runtime" : {
"requires" : {
"ExtUtils::Depends" : "0.2",
"ExtUtils::PkgConfig" : "1"
}
},
"test" : {
"recommends" : {
"Test::Number::Delta" : "1"
}
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"mailto" : "bug-Cairo [at] rt.cpan.org",
"web" : "http://rt.cpan.org/Public/Dist/Display.html?Name=Cairo"
},
"homepage" : "http://gtk2-perl.sourceforge.net",
"license" : [
"http://www.gnu.org/licenses/lgpl-2.1.html"
],
"repository" : {
"type" : "git",
"url" : "https://gitlab.gnome.org/GNOME/perl-cairo.git",
"web" : "https://gitlab.gnome.org/GNOME/perl-cairo"
},
"x_MailingList" : "https://mail.gnome.org/mailman/listinfo/gtk-perl-list"
},
"version" : "1.109",
"x_serialization_backend" : "JSON::PP version 2.97001"
}
Cairo-1.109/Cairo.xs 000644 001750 000024 00000056650 13757124331 014445 0 ustar 00brian staff 000000 000000 /*
* Copyright (c) 2004-2013 by the cairo perl team (see the file README)
*
* Licensed under the LGPL, see LICENSE file for more information.
*
* $Id$
*
*/
#include
#include
#define NEED_newRV_noinc_GLOBAL
#include "ppport.h"
/* ------------------------------------------------------------------------- */
static void
call_xs (pTHX_ void (*subaddr) (pTHX_ CV *), CV * cv, SV ** mark)
{
dSP;
PUSHMARK (mark);
(*subaddr) (aTHX_ cv);
PUTBACK; /* forget return values */
}
#ifndef XS_EXTERNAL
# define XS_EXTERNAL(name) XS(name)
#endif
#define CAIRO_PERL_CALL_BOOT(name) \
{ \
extern XS_EXTERNAL (name); \
call_xs (aTHX_ name, cv, mark); \
}
/* ------------------------------------------------------------------------- */
/* Copied from Glib/Glib.xs. */
void *
cairo_perl_alloc_temp (int nbytes)
{
dTHR;
SV * s;
if (nbytes <= 0) return NULL;
s = sv_2mortal (NEWSV (0, nbytes));
memset (SvPVX (s), 0, nbytes);
return SvPVX (s);
}
/* Copied from Glib/GType.xs. */
void
cairo_perl_set_isa (const char *child_package,
const char *parent_package)
{
char *child_isa_full;
AV *isa;
New (0, child_isa_full, strlen(child_package) + 5 + 1, char);
child_isa_full = strcpy (child_isa_full, child_package);
child_isa_full = strcat (child_isa_full, "::ISA");
isa = get_av (child_isa_full, TRUE); /* create on demand */
Safefree (child_isa_full);
av_push (isa, newSVpv (parent_package, 0));
}
/* Copied from Glib/Glib.xs. */
cairo_bool_t
cairo_perl_sv_is_defined (SV *sv)
{
/* This is adapted from PP(pp_defined) in perl's pp.c */
if (!sv || !SvANY(sv))
return FALSE;
switch (SvTYPE(sv)) {
case SVt_PVAV:
if (AvMAX(sv) >= 0 || SvGMAGICAL(sv)
|| (SvRMAGICAL(sv) && mg_find(sv, PERL_MAGIC_tied)))
return TRUE;
break;
case SVt_PVHV:
if (HvARRAY(sv) || SvGMAGICAL(sv)
|| (SvRMAGICAL(sv) && mg_find(sv, PERL_MAGIC_tied)))
return TRUE;
break;
case SVt_PVCV:
if (CvROOT(sv) || CvXSUB(sv))
return TRUE;
break;
default:
if (SvGMAGICAL(sv))
mg_get(sv);
if (SvOK(sv))
return TRUE;
}
return FALSE;
}
/* ------------------------------------------------------------------------- */
void *
cairo_object_from_sv (SV *sv, const char *package)
{
if (!cairo_perl_sv_is_ref (sv) || !sv_derived_from (sv, package))
croak("Cannot convert scalar %p to an object of type %s",
sv, package);
return INT2PTR (void *, SvIV ((SV *) SvRV (sv)));
}
SV *
cairo_object_to_sv (void *object, const char *package)
{
SV *sv = newSV (0);
sv_setref_pv(sv, package, object);
return sv;
}
/* ------------------------------------------------------------------------- */
void *
cairo_struct_from_sv (SV *sv, const char *package)
{
if (!cairo_perl_sv_is_ref (sv) || !sv_derived_from (sv, package))
croak("Cannot convert scalar %p to a struct of type %s",
sv, package);
return INT2PTR (void *, SvIV ((SV *) SvRV (sv)));
}
SV *
cairo_struct_to_sv (void *object, const char *package)
{
SV *sv = newSV (0);
sv_setref_pv(sv, package, object);
return sv;
}
/* ------------------------------------------------------------------------- */
SV *
newSVCairoFontExtents (cairo_font_extents_t *extents)
{
HV *hv;
double value;
if (!extents)
return &PL_sv_undef;
hv = newHV ();
value = extents->ascent;
hv_store (hv, "ascent", 6, newSVnv (value), 0);
value = extents->descent;
hv_store (hv, "descent", 7, newSVnv (value), 0);
value = extents->height;
hv_store (hv, "height", 6, newSVnv (value), 0);
value = extents->max_x_advance;
hv_store (hv, "max_x_advance", 13, newSVnv (value), 0);
value = extents->max_y_advance;
hv_store (hv, "max_y_advance", 13, newSVnv (value), 0);
return newRV_noinc ((SV *) hv);
}
/* ------------------------------------------------------------------------- */
SV *
newSVCairoTextExtents (cairo_text_extents_t *extents)
{
HV *hv;
double value;
if (!extents)
return &PL_sv_undef;
hv = newHV ();
value = extents->x_bearing;
hv_store (hv, "x_bearing", 9, newSVnv (value), 0);
value = extents->y_bearing;
hv_store (hv, "y_bearing", 9, newSVnv (value), 0);
value = extents->width;
hv_store (hv, "width", 5, newSVnv (value), 0);
value = extents->height;
hv_store (hv, "height", 6, newSVnv (value), 0);
value = extents->x_advance;
hv_store (hv, "x_advance", 9, newSVnv (value), 0);
value = extents->y_advance;
hv_store (hv, "y_advance", 9, newSVnv (value), 0);
return newRV_noinc ((SV *) hv);
}
/* ------------------------------------------------------------------------- */
SV *
newSVCairoGlyph (cairo_glyph_t *glyph)
{
HV *hv;
unsigned long index;
double value;
if (!glyph)
return &PL_sv_undef;
hv = newHV ();
index = glyph->index;
hv_store (hv, "index", 5, newSVuv (index), 0);
value = glyph->x;
hv_store (hv, "x", 1, newSVnv (value), 0);
value = glyph->y;
hv_store (hv, "y", 1, newSVnv (value), 0);
return newRV_noinc ((SV *) hv);
}
cairo_glyph_t *
SvCairoGlyph (SV *sv)
{
HV *hv;
SV **value;
cairo_glyph_t *glyph;
if (!cairo_perl_sv_is_hash_ref (sv))
croak ("cairo_glyph_t must be a hash reference");
hv = (HV *) SvRV (sv);
glyph = cairo_perl_alloc_temp (sizeof (cairo_glyph_t));
value = hv_fetch (hv, "index", 5, 0);
if (value && SvOK (*value))
glyph->index = SvUV (*value);
value = hv_fetch (hv, "x", 1, 0);
if (value && SvOK (*value))
glyph->x = SvNV (*value);
value = hv_fetch (hv, "y", 1, 0);
if (value && SvOK (*value))
glyph->y = SvNV (*value);
return glyph;
}
/* ------------------------------------------------------------------------- */
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
SV *
newSVCairoRectangle (cairo_rectangle_t *rectangle)
{
HV *hv;
if (!rectangle)
return &PL_sv_undef;
hv = newHV ();
hv_store (hv, "x", 1, newSVnv (rectangle->x), 0);
hv_store (hv, "y", 1, newSVnv (rectangle->y), 0);
hv_store (hv, "width", 5, newSVnv (rectangle->width), 0);
hv_store (hv, "height", 6, newSVnv (rectangle->height), 0);
return newRV_noinc ((SV *) hv);
}
cairo_rectangle_t *
SvCairoRectangle (SV *sv)
{
HV *hv;
SV **value;
cairo_rectangle_t *rectangle;
if (!cairo_perl_sv_is_hash_ref (sv))
croak ("cairo_rectangle_t must be a hash reference");
hv = (HV *) SvRV (sv);
rectangle = cairo_perl_alloc_temp (sizeof (cairo_rectangle_t));
value = hv_fetchs (hv, "x", 0);
if (value && SvOK (*value))
rectangle->x = SvNV (*value);
value = hv_fetchs (hv, "y", 0);
if (value && SvOK (*value))
rectangle->y = SvNV (*value);
value = hv_fetchs (hv, "width", 0);
if (value && SvOK (*value))
rectangle->width = SvNV (*value);
value = hv_fetchs (hv, "height", 0);
if (value && SvOK (*value))
rectangle->height = SvNV (*value);
return rectangle;
}
#endif
/* ------------------------------------------------------------------------- */
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)
SV *
newSVCairoRectangleInt (cairo_rectangle_int_t *rectangle)
{
HV *hv;
if (!rectangle)
return &PL_sv_undef;
hv = newHV ();
hv_store (hv, "x", 1, newSViv (rectangle->x), 0);
hv_store (hv, "y", 1, newSViv (rectangle->y), 0);
hv_store (hv, "width", 5, newSViv (rectangle->width), 0);
hv_store (hv, "height", 6, newSViv (rectangle->height), 0);
return newRV_noinc ((SV *) hv);
}
cairo_rectangle_int_t *
SvCairoRectangleInt (SV *sv)
{
HV *hv;
SV **value;
cairo_rectangle_int_t *rectangle;
if (!cairo_perl_sv_is_hash_ref (sv))
croak ("cairo_rectangle_int_t must be a hash reference");
hv = (HV *) SvRV (sv);
rectangle = cairo_perl_alloc_temp (sizeof (cairo_rectangle_t));
value = hv_fetchs (hv, "x", 0);
if (value && SvOK (*value))
rectangle->x = SvIV (*value);
value = hv_fetchs (hv, "y", 0);
if (value && SvOK (*value))
rectangle->y = SvIV (*value);
value = hv_fetchs (hv, "width", 0);
if (value && SvOK (*value))
rectangle->width = SvIV (*value);
value = hv_fetchs (hv, "height", 0);
if (value && SvOK (*value))
rectangle->height = SvIV (*value);
return rectangle;
}
#endif
/* ------------------------------------------------------------------------- */
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 8, 0)
SV *
newSVCairoTextCluster (cairo_text_cluster_t *cluster)
{
HV *hv;
if (!cluster)
return &PL_sv_undef;
hv = newHV ();
hv_store (hv, "num_bytes", 9, newSViv (cluster->num_bytes), 0);
hv_store (hv, "num_glyphs", 10, newSVnv (cluster->num_glyphs), 0);
return newRV_noinc ((SV *) hv);
}
cairo_text_cluster_t *
SvCairoTextCluster (SV *sv)
{
HV *hv;
SV **value;
cairo_text_cluster_t *cluster;
if (!cairo_perl_sv_is_hash_ref (sv))
croak ("cairo_text_cluster_t must be a hash reference");
hv = (HV *) SvRV (sv);
cluster = cairo_perl_alloc_temp (sizeof (cairo_text_cluster_t));
value = hv_fetch (hv, "num_bytes", 9, 0);
if (value && SvOK (*value))
cluster->num_bytes = SvIV (*value);
value = hv_fetch (hv, "num_glyphs", 10, 0);
if (value && SvOK (*value))
cluster->num_glyphs = SvIV (*value);
return cluster;
}
#endif
/* ------------------------------------------------------------------------- */
MODULE = Cairo PACKAGE = Cairo PREFIX = cairo_
BOOT:
#include "cairo-perl-boot.xsh"
#if CAIRO_PERL_DEBUG
call_atexit ((ATEXIT_t) cairo_debug_reset_static_data, NULL);
#endif
# The VERSION fallback is implemented in lib/Cairo.pm.
int LIB_VERSION (...)
CODE:
PERL_UNUSED_VAR (items);
RETVAL = CAIRO_VERSION;
OUTPUT:
RETVAL
int LIB_VERSION_ENCODE (...)
ALIAS:
VERSION_ENCODE = 1
PREINIT:
int major, minor, micro;
CODE:
PERL_UNUSED_VAR (ix);
if (items == 3) {
major = SvIV (ST (0));
minor = SvIV (ST (1));
micro = SvIV (ST (2));
} else if (items == 4) {
major = SvIV (ST (1));
minor = SvIV (ST (2));
micro = SvIV (ST (3));
} else {
croak ("Usage: Cairo::LIB_VERSION_ENCODE (major, minor, micro) or Cairo->LIB_VERSION_ENCODE (major, minor, micro)");
}
RETVAL = CAIRO_VERSION_ENCODE (major, minor, micro);
OUTPUT:
RETVAL
# int cairo_version ();
int cairo_version (class=NULL)
ALIAS:
lib_version = 1
C_ARGS:
/* void */
CLEANUP:
PERL_UNUSED_VAR (ix);
# const char* cairo_version_string ();
const char* cairo_version_string (class=NULL)
ALIAS:
lib_version_string = 1
C_ARGS:
/* void */
CLEANUP:
PERL_UNUSED_VAR (ix);
# ---------------------------------------------------------------------------- #
MODULE = Cairo PACKAGE = Cairo::Context PREFIX = cairo_
cairo_t_noinc * cairo_create (class, cairo_surface_t * target);
C_ARGS:
target
void DESTROY (cairo_t * cr);
CODE:
cairo_destroy (cr);
void cairo_save (cairo_t * cr);
void cairo_restore (cairo_t * cr);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
void cairo_push_group (cairo_t *cr);
void cairo_push_group_with_content (cairo_t *cr, cairo_content_t content);
cairo_pattern_t * cairo_pop_group (cairo_t *cr);
void cairo_pop_group_to_source (cairo_t *cr);
#endif
void cairo_set_operator (cairo_t * cr, cairo_operator_t op);
void cairo_set_source_rgb (cairo_t *cr, double red, double green, double blue);
void cairo_set_source_rgba (cairo_t *cr, double red, double green, double blue, double alpha);
void cairo_set_source (cairo_t *cr, cairo_pattern_t *source);
void cairo_set_source_surface (cairo_t *cr, cairo_surface_t *surface, double x, double y);
void cairo_set_tolerance (cairo_t * cr, double tolerance);
void cairo_set_antialias (cairo_t *cr, cairo_antialias_t antialias);
void cairo_set_fill_rule (cairo_t * cr, cairo_fill_rule_t fill_rule);
void cairo_set_line_width (cairo_t * cr, double width);
void cairo_set_line_cap (cairo_t * cr, cairo_line_cap_t line_cap);
void cairo_set_line_join (cairo_t * cr, cairo_line_join_t line_join);
##void cairo_set_dash (cairo_t * cr, double * dashes, int ndash, double offset);
void cairo_set_dash (cairo_t * cr, double offset, ...)
PREINIT:
int i, n;
double *pts;
CODE:
#define FIRST 2
n = (items - FIRST);
if (n == 0) {
pts = NULL;
} else {
New (0, pts, n, double);
if (!pts)
croak ("malloc failure for (%d) elements", n);
for (i = FIRST ; i < items ; i++)
pts[i - FIRST] = SvNV (ST (i));
}
#undef FIRST
cairo_set_dash (cr, pts, n, offset);
CLEANUP:
if (pts)
Safefree (pts);
void cairo_set_miter_limit (cairo_t * cr, double limit);
void cairo_translate (cairo_t * cr, double tx, double ty);
void cairo_scale (cairo_t * cr, double sx, double sy);
void cairo_rotate (cairo_t * cr, double angle);
void cairo_transform (cairo_t *cr, const cairo_matrix_t *matrix);
void cairo_set_matrix (cairo_t * cr, const cairo_matrix_t * matrix);
void cairo_identity_matrix (cairo_t * cr);
void cairo_user_to_device (cairo_t *cr, IN_OUTLIST double x, IN_OUTLIST double y);
void cairo_user_to_device_distance (cairo_t *cr, IN_OUTLIST double dx, IN_OUTLIST double dy);
void cairo_device_to_user (cairo_t *cr, IN_OUTLIST double x, IN_OUTLIST double y);
void cairo_device_to_user_distance (cairo_t *cr, IN_OUTLIST double dx, IN_OUTLIST double dy);
void cairo_new_path (cairo_t * cr);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
void cairo_new_sub_path (cairo_t *cr);
#endif
void cairo_move_to (cairo_t * cr, double x, double y);
void cairo_line_to (cairo_t * cr, double x, double y);
void cairo_curve_to (cairo_t * cr, double x1, double y1, double x2, double y2, double x3, double y3);
void cairo_arc (cairo_t * cr, double xc, double yc, double radius, double angle1, double angle2);
void cairo_arc_negative (cairo_t * cr, double xc, double yc, double radius, double angle1, double angle2);
void cairo_rel_move_to (cairo_t * cr, double dx, double dy);
void cairo_rel_line_to (cairo_t * cr, double dx, double dy);
void cairo_rel_curve_to (cairo_t * cr, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3);
void cairo_rectangle (cairo_t * cr, double x, double y, double width, double height);
void cairo_close_path (cairo_t * cr);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0)
void cairo_path_extents (cairo_t *cr, OUTLIST double x1, OUTLIST double y1, OUTLIST double x2, OUTLIST double y2);
#endif
void cairo_paint (cairo_t *cr);
void cairo_paint_with_alpha (cairo_t *cr, double alpha);
void cairo_mask (cairo_t *cr, cairo_pattern_t *pattern);
void cairo_mask_surface (cairo_t *cr, cairo_surface_t *surface, double surface_x, double surface_y);
void cairo_stroke (cairo_t * cr);
void cairo_stroke_preserve (cairo_t *cr);
void cairo_fill (cairo_t * cr);
void cairo_fill_preserve (cairo_t *cr);
void cairo_copy_page (cairo_t * cr);
void cairo_show_page (cairo_t * cr);
int cairo_in_stroke (cairo_t * cr, double x, double y);
int cairo_in_fill (cairo_t * cr, double x, double y);
void cairo_stroke_extents (cairo_t * cr, OUTLIST double x1, OUTLIST double y1, OUTLIST double x2, OUTLIST double y2);
void cairo_fill_extents (cairo_t * cr, OUTLIST double x1, OUTLIST double y1, OUTLIST double x2, OUTLIST double y2);
void cairo_clip (cairo_t * cr);
void cairo_clip_preserve (cairo_t *cr);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
##cairo_rectangle_list_t * cairo_copy_clip_rectangle_list (cairo_t *cr);
void cairo_copy_clip_rectangle_list (cairo_t *cr)
PREINIT:
cairo_rectangle_list_t *list;
int i;
PPCODE:
list = cairo_copy_clip_rectangle_list (cr);
CAIRO_PERL_CHECK_STATUS (list->status);
EXTEND (sp, list->num_rectangles);
for (i = 0; i < list->num_rectangles; i++)
PUSHs (sv_2mortal (newSVCairoRectangle (&(list->rectangles[i]))));
cairo_rectangle_list_destroy (list);
void cairo_clip_extents (cairo_t *cr, OUTLIST double x1, OUTLIST double y1, OUTLIST double x2, OUTLIST double y2);
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 10, 0)
cairo_bool_t cairo_in_clip (cairo_t *cr, double x, double y);
#endif
void cairo_reset_clip (cairo_t *cr);
void cairo_select_font_face (cairo_t *cr, const char_utf8 *family, cairo_font_slant_t slant, cairo_font_weight_t weight);
void cairo_set_font_size (cairo_t *cr, double size);
void cairo_set_font_matrix (cairo_t *cr, const cairo_matrix_t *matrix);
##void cairo_get_font_matrix (cairo_t *cr, cairo_matrix_t *matrix);
cairo_matrix_t * cairo_get_font_matrix (cairo_t *cr)
PREINIT:
cairo_matrix_t matrix;
CODE:
cairo_get_font_matrix (cr, &matrix);
RETVAL = cairo_perl_copy_matrix (&matrix);
OUTPUT:
RETVAL
void cairo_set_font_options (cairo_t *cr, const cairo_font_options_t *options);
##void cairo_get_font_options (cairo_t *cr, cairo_font_options_t *options);
cairo_font_options_t * cairo_get_font_options (cairo_t *cr)
CODE:
RETVAL = cairo_font_options_create ();
cairo_get_font_options (cr, RETVAL);
OUTPUT:
RETVAL
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
void cairo_set_scaled_font (cairo_t *cr, const cairo_scaled_font_t *scaled_font);
#endif
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
cairo_scaled_font_t * cairo_get_scaled_font (cairo_t *cr);
#endif
void cairo_show_text (cairo_t * cr, const char_utf8 * utf8);
##void cairo_show_glyphs (cairo_t * cr, cairo_glyph_t * glyphs, int num_glyphs);
void cairo_show_glyphs (cairo_t * cr, ...)
PREINIT:
cairo_glyph_t * glyphs = NULL;
int num_glyphs, i;
CODE:
num_glyphs = items - 1;
Newz (0, glyphs, num_glyphs, cairo_glyph_t);
for (i = 1; i < items; i++)
glyphs[i - 1] = *SvCairoGlyph (ST (i));
cairo_show_glyphs (cr, glyphs, num_glyphs);
Safefree (glyphs);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 8, 0)
##void cairo_show_text_glyphs (cairo_t *cr, const char *utf8, int utf8_len, const cairo_glyph_t *glyphs, int num_glyphs, const cairo_text_cluster_t *clusters, int num_clusters, cairo_text_cluster_flags_t cluster_flags);
void
cairo_show_text_glyphs (cairo_t *cr, SV *utf8_sv, SV *glyphs_sv, SV *clusters_sv, cairo_text_cluster_flags_t cluster_flags)
PREINIT:
const char *utf8 = NULL;
STRLEN utf8_len = 0;
cairo_glyph_t * glyphs = NULL;
cairo_text_cluster_t * clusters = NULL;
int i, num_glyphs, num_clusters;
AV *glyphs_av, *clusters_av;
CODE:
if (!cairo_perl_sv_is_array_ref (glyphs_sv))
croak ("glyphs must be an array ref");
if (!cairo_perl_sv_is_array_ref (clusters_sv))
croak ("text clusters must be an array ref");
sv_utf8_upgrade (utf8_sv);
utf8 = SvPV (utf8_sv, utf8_len);
glyphs_av = (AV *) SvRV (glyphs_sv);
num_glyphs = av_len (glyphs_av) + 1;
glyphs = cairo_glyph_allocate (num_glyphs);
for (i = 0; i < num_glyphs; i++) {
SV **value = av_fetch (glyphs_av, i, 0);
if (value)
glyphs[i] = *SvCairoGlyph (*value);
}
clusters_av = (AV *) SvRV (clusters_sv);
num_clusters = av_len (clusters_av) + 1;
clusters = cairo_text_cluster_allocate (num_clusters);
for (i = 0; i < num_clusters; i++) {
SV **value = av_fetch (clusters_av, i, 0);
if (value)
clusters[i] = *SvCairoTextCluster (*value);
}
cairo_show_text_glyphs (cr,
utf8, (int) utf8_len,
glyphs, num_glyphs,
clusters, num_clusters, cluster_flags);
cairo_text_cluster_free (clusters);
cairo_glyph_free (glyphs);
#endif
cairo_font_face_t * cairo_get_font_face (cairo_t *cr);
##void cairo_font_extents (cairo_t *cr, cairo_font_extents_t *extents);
cairo_font_extents_t * cairo_font_extents (cairo_t *cr)
PREINIT:
cairo_font_extents_t extents;
CODE:
cairo_font_extents (cr, &extents);
RETVAL = &extents;
OUTPUT:
RETVAL
void cairo_set_font_face (cairo_t *cr, cairo_font_face_t *font_face);
##void cairo_text_extents (cairo_t * cr, const char * utf8, cairo_text_extents_t * extents);
cairo_text_extents_t * cairo_text_extents (cairo_t * cr, const char_utf8 * utf8)
PREINIT:
cairo_text_extents_t extents;
CODE:
cairo_text_extents (cr, utf8, &extents);
RETVAL = &extents;
OUTPUT:
RETVAL
##void cairo_glyph_extents (cairo_t * cr, cairo_glyph_t * glyphs, int num_glyphs, cairo_text_extents_t * extents);
cairo_text_extents_t * cairo_glyph_extents (cairo_t * cr, ...)
PREINIT:
cairo_text_extents_t extents;
cairo_glyph_t * glyphs = NULL;
int num_glyphs, i;
CODE:
num_glyphs = items - 1;
Newz (0, glyphs, num_glyphs, cairo_glyph_t);
for (i = 1; i < items; i++)
glyphs[i - 1] = *SvCairoGlyph (ST (i));
cairo_glyph_extents (cr, glyphs, num_glyphs, &extents);
RETVAL = &extents;
Safefree (glyphs);
OUTPUT:
RETVAL
void cairo_text_path (cairo_t * cr, const char_utf8 * utf8);
##void cairo_glyph_path (cairo_t * cr, cairo_glyph_t * glyphs, int num_glyphs);
void cairo_glyph_path (cairo_t * cr, ...)
PREINIT:
cairo_glyph_t * glyphs = NULL;
int num_glyphs, i;
CODE:
num_glyphs = items - 1;
Newz (0, glyphs, num_glyphs, cairo_glyph_t);
for (i = 1; i < items; i++)
glyphs[i - 1] = *SvCairoGlyph (ST (i));
cairo_glyph_path (cr, glyphs, num_glyphs);
Safefree (glyphs);
cairo_operator_t cairo_get_operator (cairo_t *cr);
cairo_pattern_t * cairo_get_source (cairo_t *cr);
double cairo_get_tolerance (cairo_t *cr);
cairo_antialias_t cairo_get_antialias (cairo_t *cr);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 6, 0)
cairo_bool_t cairo_has_current_point (cairo_t *cr);
#endif
void cairo_get_current_point (cairo_t *cr, OUTLIST double x, OUTLIST double y);
cairo_fill_rule_t cairo_get_fill_rule (cairo_t *cr);
double cairo_get_line_width (cairo_t *cr);
cairo_line_cap_t cairo_get_line_cap (cairo_t *cr);
cairo_line_join_t cairo_get_line_join (cairo_t *cr);
double cairo_get_miter_limit (cairo_t *cr);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 4, 0)
## int cairo_get_dash_count (cairo_t *cr);
## void cairo_get_dash (cairo_t *cr, double *dashes, double *offset);
void cairo_get_dash (cairo_t *cr)
PREINIT:
int count, i;
double *dashes, offset;
PPCODE:
count = cairo_get_dash_count (cr);
if (count == 0) {
dashes = NULL;
} else {
New (0, dashes, count, double);
if (!dashes)
croak ("malloc failure for (%d) elements", count);
}
cairo_get_dash (cr, dashes, &offset);
EXTEND (sp, count + 1);
PUSHs (sv_2mortal (newSVnv (offset)));
for (i = 0; i < count; i++)
PUSHs (sv_2mortal (newSVnv (dashes[i])));
Safefree (dashes);
#endif
##void cairo_get_matrix (cairo_t *cr, cairo_matrix_t *matrix);
cairo_matrix_t * cairo_get_matrix (cairo_t *cr)
PREINIT:
cairo_matrix_t matrix;
CODE:
cairo_get_matrix (cr, &matrix);
RETVAL = cairo_perl_copy_matrix (&matrix);
OUTPUT:
RETVAL
cairo_surface_t * cairo_get_target (cairo_t *cr);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 2, 0)
cairo_surface_t * cairo_get_group_target (cairo_t *cr);
#endif
cairo_path_t * cairo_copy_path (cairo_t *cr);
cairo_path_t * cairo_copy_path_flat (cairo_t *cr);
void cairo_append_path (cairo_t *cr, cairo_path_t *path);
cairo_status_t cairo_status (cairo_t *cr);
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 16, 0)
void cairo_tag_begin (cairo_t * cr, const char_utf8 * tag_name, const char_utf8 * attributes);
void cairo_tag_end (cairo_t * cr, const char_utf8 * tag_name);
BOOT:
HV *stash = gv_stashpv("Cairo", 0);
newCONSTSUB (stash, "TAG_DEST", newSVpv (CAIRO_TAG_DEST, 0));
newCONSTSUB (stash, "TAG_LINK", newSVpv (CAIRO_TAG_LINK, 0));
#endif
# --------------------------------------------------------------------------- #
MODULE = Cairo PACKAGE = Cairo PREFIX = cairo_
bool
HAS_PS_SURFACE ()
CODE:
#ifdef CAIRO_HAS_PS_SURFACE
RETVAL = TRUE;
#else
RETVAL = FALSE;
#endif
OUTPUT:
RETVAL
bool
HAS_PDF_SURFACE ()
CODE:
#ifdef CAIRO_HAS_PDF_SURFACE
RETVAL = TRUE;
#else
RETVAL = FALSE;
#endif
OUTPUT:
RETVAL
bool
HAS_SVG_SURFACE ()
CODE:
#ifdef CAIRO_HAS_SVG_SURFACE
RETVAL = TRUE;
#else
RETVAL = FALSE;
#endif
OUTPUT:
RETVAL
bool
HAS_RECORDING_SURFACE ()
CODE:
#ifdef CAIRO_HAS_RECORDING_SURFACE
RETVAL = TRUE;
#else
RETVAL = FALSE;
#endif
OUTPUT:
RETVAL
bool
HAS_FT_FONT ()
CODE:
#ifdef CAIRO_HAS_FT_FONT
RETVAL = TRUE;
#else
RETVAL = FALSE;
#endif
OUTPUT:
RETVAL
bool
HAS_PNG_FUNCTIONS ()
CODE:
#ifdef CAIRO_HAS_PNG_FUNCTIONS
RETVAL = TRUE;
#else
RETVAL = FALSE;
#endif
OUTPUT:
RETVAL
Cairo-1.109/lib/Cairo.pm 000644 001750 000024 00000072063 14001743323 015160 0 ustar 00brian staff 000000 000000 #
# Copyright (c) 2004-2013 by the cairo perl team (see the file README)
#
# Licensed under the LGPL, see LICENSE file for more information.
#
# $Id$
#
package Cairo;
use strict;
use warnings;
use DynaLoader;
our @ISA = qw/DynaLoader/;
our $VERSION = '1.109';
sub dl_load_flags { $^O eq 'darwin' ? 0x00 : 0x01 }
Cairo->bootstrap ($VERSION);
# Our Cairo::VERSION used to be a simple wrapper around CAIRO_VERSION. But a
# package's VERSION sub is supposed to do Perl version checking so that things
# like 'use Cairo 1.00' work. To not break backwards-compatibility, we
# dispatch according to the number of arguments passed in.
sub VERSION {
if (scalar @_ == 2) {
shift->SUPER::VERSION (@_);
} else {
Cairo::LIB_VERSION (@_);
}
}
1;
__END__
=head1 NAME
Cairo - Perl interface to the cairo 2d vector graphics library
=head1 SYNOPSIS
use Cairo;
my $surface = Cairo::ImageSurface->create ('argb32', 100, 100);
my $cr = Cairo::Context->create ($surface);
$cr->rectangle (10, 10, 40, 40);
$cr->set_source_rgb (0, 0, 0);
$cr->fill;
$cr->rectangle (50, 50, 40, 40);
$cr->set_source_rgb (1, 1, 1);
$cr->fill;
$cr->show_page;
$surface->write_to_png ('output.png');
=head1 ABSTRACT
Cairo provides Perl bindings for the vector graphics library cairo. It
supports multiple output targets, including PNG, PDF and SVG. Cairo produces
identical output on all those targets.
=head1 API DOCUMENTATION
This is a listing of the API Cairo provides. For more verbose information,
refer to the cairo manual at L.
=head2 Drawing
=head3 Cairo::Context -- The cairo drawing context
I is the main object used when drawing with Cairo. To draw with
Cairo, you create a I, set the target surface, and drawing
options for the I, create shapes with methods like
C<$cr-Emove_to> and C<$cr-Eline_to>, and then draw shapes with
C<$cr-Estroke> or C<$cr-Efill>.
I's can be pushed to a stack via C<$cr-Esave>. They may
then safely be changed, without loosing the current state. Use
C<$cr-Erestore> to restore to the saved state.
=over
=item $cr = Cairo::Context->create ($surface)
=over
=item $surface: I
=back
=item $cr-Esave
=item $cr->restore
=item $status = $cr->status
=item $surface = $cr->get_target
=item $cr->push_group [1.2]
=item $cr->push_group_with_content ($content) [1.2]
=over
=item $content: I
=back
=item $pattern = $cr->pop_group [1.2]
=item $cr->pop_group_to_source [1.2]
=item $surface = $cr->get_group_target [1.2]
=item $cr->set_source_rgb ($red, $green, $blue)
=over
=item $red: double
=item $green: double
=item $blue: double
=back
=item $cr->set_source_rgba ($red, $green, $blue, $alpha)
=over
=item $red: double
=item $green: double
=item $blue: double
=item $alpha: double
=back
=item $cr->set_source ($source)
=over
=item $source: I
=back
=item $cr->set_source_surface ($surface, $x, $y)
=over
=item $surface: I
=item $x: double
=item $y: double
=back
=item $source = $cr->get_source
=item $cr->set_antialias ($antialias)
=over
=item $antialias: I
=back
=item $antialias = $cr->get_antialias
=item $cr->set_dash ($offset, ...)
=over
=item $offset: double
=item ...: list of doubles
=back
=item $cr->set_fill_rule ($fill_rule)
=over
=item $fill_rule: I
=back
=item $fill_rule = $cr->get_fill_rule
=item $cr->set_line_cap ($line_cap)
=over
=item $line_cap: I
=back
=item $line_cap = $cr->get_line_cap
=item $cr->set_line_join ($line_join)
=over
=item $line_join: I
=back
=item $line_join = $cr->get_line_join
=item $cr->set_line_width ($width)
=over
=item $width: double
=back
=item $width = $cr->get_line_width
=item $cr->set_miter_limit ($limit)
=over
=item $limit: double
=back
=item ($offset, @dashes) = $cr->get_dash [1.4]
=item $limit = $cr->get_miter_limit
=item $cr->set_operator ($op)
=over
=item $op: I
=back
=item $op = $cr->get_operator
=item $cr->set_tolerance ($tolerance)
=over
=item $tolerance: double
=back
=item $tolerance = $cr->get_tolerance
=item $cr->clip
=item $cr->clip_preserve
=item ($x1, $y1, $x2, $y2) = $cr->clip_extents [1.4]
=item $bool = $cr->in_clip ($x, $y) [1.10]
=over
=item $x: double
=item $y: double
=back
=item @rectangles = $cr->copy_clip_rectangle_list [1.4]
=item $cr->reset_clip
=item $cr->fill
=item $cr->fill_preserve
=item ($x1, $y1, $x2, $y2) = $cr->fill_extents
=item $bool = $cr->in_fill ($x, $y)
=over
=item $x: double
=item $y: double
=back
=item $cr->mask ($pattern)
=over
=item $pattern: I
=back
=item $cr->mask_surface ($surface, $surface_x, $surface_y)
=over
=item $surface: I
=item $surface_x: double
=item $surface_y: double
=back
=item $cr->paint
=item $cr->paint_with_alpha ($alpha)
=over
=item $alpha: double
=back
=item $cr->stroke
=item $cr->stroke_preserve
=item ($x1, $y1, $x2, $y2) = $cr->stroke_extents
=item $bool = $cr->in_stroke ($x, $y)
=over
=item $x: double
=item $y: double
=back
=item $cr->tag_begin($name, $atts) [1.16]
=over
=item $name: string
=item $atts: string
=back
=item $cr->tag_end($name) [1.16]
=over
=item $name: string
=back
=item Predefined names:
=over
=item Cairo::TAG_DEST [1.16]
=item Cairo::TAG_LINK [1.16]
=back
=item $cr->copy_page
=item $cr->show_page
=back
=cut
# --------------------------------------------------------------------------- #
=head3 Paths -- Creating paths and manipulating path data
$path = [
{ type => "move-to", points => [[1, 2]] },
{ type => "line-to", points => [[3, 4]] },
{ type => "curve-to", points => [[5, 6], [7, 8], [9, 10]] },
...
{ type => "close-path", points => [] },
];
I is a data structure for holding a path. This data structure
serves as the return value for C<$cr-Ecopy_path> and
C<$cr-Ecopy_path_flat> as well the input value for
C<$cr-Eappend_path>.
I is represented as an array reference that contains path
elements, represented by hash references with two keys: I and I.
The value for I can be either of the following:
=over
=item C
=item C
=item C
=item C
=back
The value for I is an array reference which contains zero or more
points. Points are represented as array references that contain two doubles:
I and I. The necessary number of points depends on the I of the
path element:
=over
=item C: 1 point
=item C: 1 point
=item C: 3 points
=item C: 0 points
=back
The semantics and ordering of the coordinate values are consistent with
C<$cr-Emove_to>, C<$cr-Eline_to>, C<$cr-Ecurve_to>, and
C<$cr-Eclose_path>.
Note that the paths returned by Cairo are implemented as tied array references
which do B support adding, removing or shuffling of path segments. For
these operations, you need to make a shallow copy first:
my @path_clone = @{$path};
# now you can alter @path_clone which ever way you want
The points of a single path element can be changed directly, however, without
the need for a shallow copy:
$path->[$i]{points} = [[3, 4], [5, 6], [7, 8]];
=over
=item $path = $cr->copy_path
=item $path = $cr->copy_path_flat
=item $cr->append_path ($path)
=over
=item $path: I
=back
=item $bool = $cr->has_current_point [1.6]
=item ($x, $y) = $cr->get_current_point
=item $cr->new_path
=item $cr->new_sub_path [1.2]
=item $cr->close_path
=item ($x1, $y1, $x2, $y2) = $cr->path_extents [1.6]
=item $cr->arc ($xc, $yc, $radius, $angle1, $angle2)
=over
=item $xc: double
=item $yc: double
=item $radius: double
=item $angle1: double
=item $angle2: double
=back
=item $cr->arc_negative ($xc, $yc, $radius, $angle1, $angle2)
=over
=item $xc: double
=item $yc: double
=item $radius: double
=item $angle1: double
=item $angle2: double
=back
=item $cr->curve_to ($x1, $y1, $x2, $y2, $x3, $y3)
=over
=item $x1: double
=item $y1: double
=item $x2: double
=item $y2: double
=item $x3: double
=item $y3: double
=back
=item $cr->line_to ($x, $y)
=over
=item $x: double
=item $y: double
=back
=item $cr->move_to ($x, $y)
=over
=item $x: double
=item $y: double
=back
=item $cr->rectangle ($x, $y, $width, $height)
=over
=item $x: double
=item $y: double
=item $width: double
=item $height: double
=back
=item $cr->glyph_path (...)
=over
=item ...: list of I's
=back
=item $cr->text_path ($utf8)
=over
=item $utf8: string in utf8 encoding
=back
=item $cr->rel_curve_to ($dx1, $dy1, $dx2, $dy2, $dx3, $dy3)
=over
=item $dx1: double
=item $dy1: double
=item $dx2: double
=item $dy2: double
=item $dx3: double
=item $dy3: double
=back
=item $cr->rel_line_to ($dx, $dy)
=over
=item $dx: double
=item $dy: double
=back
=item $cr->rel_move_to ($dx, $dy)
=over
=item $dx: double
=item $dy: double
=back
=back
=cut
# --------------------------------------------------------------------------- #
=head3 Patterns -- Gradients and filtered sources
=over
=item $status = $pattern->status
=item $type = $pattern->get_type [1.2]
=item $pattern->set_extend ($extend)
=over
=item $extend: I
=back
=item $extend = $pattern->get_extend
=item $pattern->set_filter ($filter)
=over
=item $filter: I
=back
=item $filter = $pattern->get_filter
=item $pattern->set_matrix ($matrix)
=over
=item $matrix: I
=back
=item $matrix = $pattern->get_matrix
=item $pattern = Cairo::SolidPattern->create_rgb ($red, $green, $blue)
=over
=item $red: double
=item $green: double
=item $blue: double
=back
=item $pattern = Cairo::SolidPattern->create_rgba ($red, $green, $blue, $alpha)
=over
=item $red: double
=item $green: double
=item $blue: double
=item $alpha: double
=back
=item ($r, $g, $b, $a) = $pattern->get_rgba [1.4]
=item $pattern = Cairo::SurfacePattern->create ($surface)
=over
=item $surface: I
=back
=item $surface = $pattern->get_surface [1.4]
=item $pattern = Cairo::LinearGradient->create ($x0, $y0, $x1, $y1)
=over
=item $x0: double
=item $y0: double
=item $x1: double
=item $y1: double
=back
=item ($x0, $y0, $x1, $y1) = $pattern->get_points [1.4]
=item $pattern = Cairo::RadialGradient->create ($cx0, $cy0, $radius0, $cx1, $cy1, $radius1)
=over
=item $cx0: double
=item $cy0: double
=item $radius0: double
=item $cx1: double
=item $cy1: double
=item $radius1: double
=back
=item ($x0, $y0, $r0, $x1, $y1, $r1) = $pattern->get_circles [1.4]
=item $pattern->add_color_stop_rgb ($offset, $red, $green, $blue)
=over
=item $offset: double
=item $red: double
=item $green: double
=item $blue: double
=back
=item $pattern->add_color_stop_rgba ($offset, $red, $green, $blue, $alpha)
=over
=item $offset: double
=item $red: double
=item $green: double
=item $blue: double
=item $alpha: double
=back
=item @stops = $pattern->get_color_stops [1.4]
A color stop is represented as an array reference with five elements: offset,
red, green, blue, and alpha.
=back
=cut
# --------------------------------------------------------------------------- #
=head3 Regions -- Representing a pixel-aligned area
=over
=item $region = Cairo::Region->create (...) [1.10]
=over
=item ...: zero or more I
=back
=item $status = $region->status [1.10]
=item $num = $region->num_rectangles [1.10]
=item $rect = $region->get_rectangle ($i) [1.10]
=over
=item $i: integer
=back
=item $bool = $region->is_empty [1.10]
=item $bool = $region->contains_point ($x, $y) [1.10]
=over
=item $x: integer
=item $y: integer
=back
=item $bool = $region_one->equal ($region_two) [1.10]
=over
=item $region_two: I
=back
=item $region->translate ($dx, $dy) [1.10]
=over
=item $dx: integer
=item $dy: integer
=back
=item $status = $dst->intersect ($other) [1.10]
=item $status = $dst->intersect_rectangle ($rect) [1.10]
=item $status = $dst->subtract ($other) [1.10]
=item $status = $dst->subtract_rectangle ($rect) [1.10]
=item $status = $dst->union ($other) [1.10]
=item $status = $dst->union_rectangle ($rect) [1.10]
=item $status = $dst->xor ($other) [1.10]
=item $status = $dst->xor_rectangle ($rect) [1.10]
=over
=item $other: I
=item $rect: I
=back
=back
=cut
# --------------------------------------------------------------------------- #
=head3 Transformations -- Manipulating the current transformation matrix
=over
=item $cr->translate ($tx, $ty)
=over
=item $tx: double
=item $ty: double
=back
=item $cr->scale ($sx, $sy)
=over
=item $sx: double
=item $sy: double
=back
=item $cr->rotate ($angle)
=over
=item $angle: double
=back
=item $cr->transform ($matrix)
=over
=item $matrix: I
=back
=item $cr->set_matrix ($matrix)
=over
=item $matrix: I
=back
=item $matrix = $cr->get_matrix
=item $cr->identity_matrix
=item ($x, $y) = $cr->user_to_device ($x, $y)
=over
=item $x: double
=item $y: double
=back
=item ($dx, $dy) = $cr->user_to_device_distance ($dx, $dy)
=over
=item $dx: double
=item $dy: double
=back
=item ($x, $y) = $cr->device_to_user ($x, $y)
=over
=item $x: double
=item $y: double
=back
=item ($dx, $dy) = $cr->device_to_user_distance ($dx, $dy)
=over
=item $dx: double
=item $dy: double
=back
=back
=cut
# --------------------------------------------------------------------------- #
=head3 Text -- Rendering text and sets of glyphs
Glyphs are represented as anonymous hash references with three keys: I,
I and I. Example:
my @glyphs = ({ index => 1, x => 2, y => 3 },
{ index => 2, x => 3, y => 4 },
{ index => 3, x => 4, y => 5 });
=over
=item $cr->select_font_face ($family, $slant, $weight)
=over
=item $family: string
=item $slant: I
=item $weight: I
=back
=item $cr->set_font_size ($size)
=over
=item $size: double
=back
=item $cr->set_font_matrix ($matrix)
=over
=item $matrix: I
=back
=item $matrix = $cr->get_font_matrix
=item $cr->set_font_options ($options)
=over
=item $options: I
=back
=item $options = $cr->get_font_options
=item $cr->set_scaled_font ($scaled_font) [1.2]
=over
=item $scaled_font: I
=back
=item $scaled_font = $cr->get_scaled_font [1.4]
=item $cr->show_text ($utf8)
=over
=item $utf8: string
=back
=item $cr->show_glyphs (...)
=over
=item ...: list of glyphs
=back
=item $cr->show_text_glyphs ($utf8, $glyphs, $clusters, $cluster_flags) [1.8]
=over
=item $utf8: string
=item $glyphs: array ref of glyphs
=item $clusters: array ref of clusters
=item $cluster_flags: I
=back
=item $face = $cr->get_font_face
=item $extents = $cr->font_extents
=item $cr->set_font_face ($font_face)
=over
=item $font_face: I
=back
=item $cr->set_scaled_font ($scaled_font)
=over
=item $scaled_font: I
=back
=item $extents = $cr->text_extents ($utf8)
=over
=item $utf8: string
=back
=item $extents = $cr->glyph_extents (...)
=over
=item ...: list of glyphs
=back
=item $face = Cairo::ToyFontFace->create ($family, $slant, $weight) [1.8]
=over
=item $family: string
=item $slant: I
=item $weight: I
=back
=item $family = $face->get_family [1.8]
=item $slang = $face->get_slant [1.8]
=item $weight = $face->get_weight [1.8]
=back
=cut
# --------------------------------------------------------------------------- #
=head2 Fonts
=head3 Cairo::FontFace -- Base class for fonts
=over
=item $status = $font_face->status
=item $type = $font_face->get_type [1.2]
=back
=cut
# --------------------------------------------------------------------------- #
=head3 Scaled Fonts -- Caching metrics for a particular font size
=over
=item $scaled_font = Cairo::ScaledFont->create ($font_face, $font_matrix, $ctm, $options)
=over
=item $font_face: I
=item $font_matrix: I
=item $ctm: I
=item $options: I
=back
=item $status = $scaled_font->status
=item $extents = $scaled_font->extents
=item $extents = $scaled_font->text_extents ($utf8) [1.2]
=over
=item $utf8: string
=back
=item $extents = $scaled_font->glyph_extents (...)
=over
=item ...: list of glyphs
=back
=item ($status, $glyphs, $clusters, $cluster_flags) = $scaled_font->text_to_glyphs ($x, $y, $utf8) [1.8]
=over
=item $x: double
=item $y: double
=item $utf8: string
=back
=item $font_face = $scaled_font->get_font_face [1.2]
=item $options = $scaled_font->get_font_options [1.2]
=item $font_matrix = $scaled_font->get_font_matrix [1.2]
=item $ctm = $scaled_font->get_ctm [1.2]
=item $scale_matrix = $scaled_font->get_scale_matrix [1.8]
=item $type = $scaled_font->get_type [1.2]
=back
=cut
# --------------------------------------------------------------------------- #
=head3 Font Options -- How a font should be rendered
=over
=item $font_options = Cairo::FontOptions->create
=item $status = $font_options->status
=item $font_options->merge ($other)
=over
=item $other: I
=back
=item $hash = $font_options->hash
=item $bools = $font_options->equal ($other)
=over
=item $other: I
=back
=item $font_options->set_antialias ($antialias)
=over
=item $antialias: I
=back
=item $antialias = $font_options->get_antialias
=item $font_options->set_subpixel_order ($subpixel_order)
=over
=item $subpixel_order: I
=back
=item $subpixel_order = $font_options->get_subpixel_order
=item $font_options->set_hint_style ($hint_style)
=over
=item $hint_style: I
=back
=item $hint_style = $font_options->get_hint_style
=item $font_options->set_hint_metrics ($hint_metrics)
=over
=item $hint_metrics: I
=back
=item $hint_metrics = $font_options->get_hint_metrics
=back
=cut
# --------------------------------------------------------------------------- #
=head3 FreeType Fonts -- Font support for FreeType
If your cairo library supports it, the FreeType integration allows you to load
font faces from font files. You can query for this capability with
C. To actually use this, you'll need the L
module.
=over
=item my $face = Cairo::FtFontFace->create ($ft_face, $load_flags=0)
=over
=item $ft_face: I
=item $load_flags: integer
=back
This method allows you to create a I from a
I. To obtain the latter, you can for example load it
from a file:
my $file = '/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf';
my $ft_face = Font::FreeType->new->face ($file);
my $face = Cairo::FtFontFace->create ($ft_face);
=back
=cut
# --------------------------------------------------------------------------- #
=head2 Surfaces
=head3 I -- Base class for surfaces
=over
=item $similar = Cairo::Surface->create_similar ($other, $content, $width, $height)
=over
=item $other: I
=item $content: I
=item $width: integer
=item $height: integer
=back
For hysterical reasons, you can also use the following syntax:
$similar = $other->create_similar ($content, $width, $height)
=item $new = Cairo::Surface->create_for_rectangle ($target, $x, $y, $width, $height) [1.10]
=over
=item $target: I
=item $x: double
=item $y: double
=item $width: double
=item $height: double
=back
=item $status = $surface->status
=item $surface->finish
=item $surface->flush
=item $font_options = $surface->get_font_options
=item $content = $surface->get_content [1.2]
=item $surface->mark_dirty
=item $surface->mark_dirty_rectangle ($x, $y, $width, $height)
=over
=item $x: integer
=item $y: integer
=item $width: integer
=item $height: integer
=back
=item $surface->set_device_offset ($x_offset, $y_offset)
=over
=item $x_offset: integer
=item $y_offset: integer
=back
=item ($x_offset, $y_offset) = $surface->get_device_offset [1.2]
=item $surface->set_fallback_resolution ($x_pixels_per_inch, $y_pixels_per_inch) [1.2]
=over
=item $x_pixels_per_inch: double
=item $y_pixels_per_inch: double
=back
=item ($x_pixels_per_inch, $y_pixels_per_inch) = $surface->get_fallback_resolution [1.8]
=item $type = $surface->get_type [1.2]
=item $surface->set_mime_data ($mime_type, $mime_data) [1.10]
=item $mime_data = $surface->get_mime_data ($mime_type) [1.10]
=item $bool = $surface->supports_mime_type ($mime_type) [1.12]
=over
=item $mime_type: string
=over
=item Predefined MIME types:
=over
=item Cairo::Surface::MIME_TYPE_JP2 [1.10]
=item Cairo::Surface::MIME_TYPE_JPEG [1.10]
=item Cairo::Surface::MIME_TYPE_PNG [1.10]
=item Cairo::Surface::MIME_TYPE_URI [1.10]
=item Cairo::Surface::MIME_TYPE_UNIQUE_ID [1.12]
=item Cairo::Surface::MIME_TYPE_JBIG2 [1.14]
=item Cairo::Surface::MIME_TYPE_JBIG2_GLOBAL [1.14]
=item Cairo::Surface::MIME_TYPE_JBIG2_GLOBAL_PARAMS [1.14]
=item Cairo::Surface::MIME_TYPE_CCITT_FAX [1.16]
=item Cairo::Surface::MIME_TYPE_CCITT_FAX_PARAMS [1.16]
=item Cairo::Surface::MIME_TYPE_EPS [1.16]
=item Cairo::Surface::MIME_TYPE_EPS_PARAMS [1.16]
=back
=back
=item $mime_data: binary data string
=back
=item $status = $surface->copy_page [1.6]
=over
=item $status: I
=back
=item $status = $surface->show_page [1.6]
=over
=item $status: I
=back
=item $boolean = $surface->has_show_text_glyphs [1.8]
=back
=cut
# --------------------------------------------------------------------------- #
=head3 Image Surfaces -- Rendering to memory buffers
=over
=item $surface = Cairo::ImageSurface->create ($format, $width, $height)
=over
=item $format: I
=item $width: integer
=item $height: integer
=back
=item $surface = Cairo::ImageSurface->create_for_data ($data, $format, $width, $height, $stride)
=over
=item $data: image data
=item $format: I
=item $width: integer
=item $height: integer
=item $stride: integer
=back
=item $data = $surface->get_data [1.2]
=item $format = $surface->get_format [1.2]
=item $width = $surface->get_width
=item $height = $surface->get_height
=item $stride = $surface->get_stride [1.2]
=item $stride = Cairo::Format::stride_for_width ($format, $width) [1.6]
=over
=item $format: I
=item $width: integer
=back
=back
=cut
# --------------------------------------------------------------------------- #
=head3 PDF Surfaces -- Rendering PDF documents
=over
=item $surface = Cairo::PdfSurface->create ($filename, $width_in_points, $height_in_points) [1.2]
=over
=item $filename: string
=item $width_in_points: double
=item $height_in_points: double
=back
=item $surface = Cairo::PdfSurface->create_for_stream ($callback, $callback_data, $width_in_points, $height_in_points) [1.2]
=over
=item $callback: I
=item $callback_data: scalar
=item $width_in_points: double
=item $height_in_points: double
=back
=item $surface->set_size ($width_in_points, $height_in_points) [1.2]
=over
=item $width_in_points: double
=item $height_in_points: double
=back
=item $surface->restrict_to_version ($version) [1.10]
=over
=item $version: I
=back
=item @versions = Cairo::PdfSurface::get_versions [1.10]
=item $string = Cairo::PdfSurface::version_to_string ($version) [1.10]
=over
=item $version: I
=back
=item $item_id = $surface->add_outline($parent_id, $name, $attributes, $flags) [1.16]
=over
=item $item_id: int, item ID
=item $parent_id: parent item id or Cairo::PdfSurface::OUTLINE_ROOT
=item $name: string, item display
=item $attributes: string, item attributes
=item $flags: list reference, item flags
=back
=item $surface->set_metadata($name, $value) [1.16]
=over
=item $name: string
=item $value: string
=back
=item $surface->set_page_label($label) [1.16]
=over
=item $label: string, page label
=back
=item $surface->set_thumbnail_size($width, $height) [1.16]
=over
=item $width: int, thumbnail width
=item $height: int, thumbnail height
=back
=back
=cut
# --------------------------------------------------------------------------- #
=head3 PNG Support -- Reading and writing PNG images
=over
=item $surface = Cairo::ImageSurface->create_from_png ($filename)
=over
=item $filename: string
=back
=item Cairo::ReadFunc: $data = sub { my ($callback_data, $length) = @_; }
=over
=item $data: binary image data, of length $length
=item $callback_data: scalar, user data
=item $length: integer, bytes to read
=back
=item $surface = Cairo::ImageSurface->create_from_png_stream ($callback, $callback_data)
=over
=item $callback: I
=item $callback_data: scalar
=back
=item $status = $surface->write_to_png ($filename)
=over
=item $filename: string
=back
=item Cairo::WriteFunc: sub { my ($callback_data, $data) = @_; }
=over
=item $callback_data: scalar, user data
=item $data: binary image data, to be written
=back
=item $status = $surface->write_to_png_stream ($callback, $callback_data)
=over
=item $callback: I
=item $callback_data: scalar
=back
=back
=cut
# --------------------------------------------------------------------------- #
=head3 PostScript Surfaces -- Rendering PostScript documents
=over
=item $surface = Cairo::PsSurface->create ($filename, $width_in_points, $height_in_points) [1.2]
=over
=item $filename: string
=item $width_in_points: double
=item $height_in_points: double
=back
=item $surface = Cairo::PsSurface->create_for_stream ($callback, $callback_data, $width_in_points, $height_in_points) [1.2]
=over
=item $callback: I
=item $callback_data: scalar
=item $width_in_points: double
=item $height_in_points: double
=back
=item $surface->set_size ($width_in_points, $height_in_points) [1.2]
=over
=item $width_in_points: double
=item $height_in_points: double
=back
=item $surface->dsc_begin_setup [1.2]
=item $surface->dsc_begin_page_setup [1.2]
=item $surface->dsc_comment ($comment) [1.2]
=over
=item $comment: string
=back
=item $surface->restrict_to_level ($level) [1.6]
=over
=item $level: I
=back
=item @levels = Cairo::PsSurface::get_levels [1.6]
=item $string = Cairo::PsSurface::level_to_string ($level) [1.6]
=over
=item $level: I
=back
=item $surface->set_eps ($eps) [1.6]
=over
=item $eps: boolean
=back
=item $eps = $surface->get_eps [1.6]
=back
=cut
# --------------------------------------------------------------------------- #
=head3 Recording Surfaces -- Records all drawing operations
=over
=item $surface = Cairo::RecordingSurface->create ($content, $extents) [1.10]
=over
=item $content: I
=item $extents: I
=back
=item ($x0, $y0, $width, $height) = $surface->ink_extents [1.10]
=item $extents_ref = $surface->get_extents [1.12]
=over
=item $extents_ref: I reference
=back
=back
=cut
# --------------------------------------------------------------------------- #
=head3 SVG Surfaces -- Rendering SVG documents
=over
=item $surface = Cairo::SvgSurface->create ($filename, $width_in_points, $height_in_points) [1.2]
=over
=item $filename: string
=item $width_in_points: double
=item $height_in_points: double
=back
=item $surface = Cairo::SvgSurface->create_for_stream ($callback, $callback_data, $width_in_points, $height_in_points) [1.2]
=over
=item $callback: I
=item $callback_data: scalar
=item $width_in_points: double
=item $height_in_points: double
=back
=item $surface->restrict_to_version ($version) [1.2]
=over
=item $version: I
=back
=item @versions = Cairo::SvgSurface::get_versions [1.2]
=item $string = Cairo::SvgSurface::version_to_string ($version) [1.2]
=over
=item $version: I
=back
=back
=cut
# --------------------------------------------------------------------------- #
=head2 Utilities
=head3 Version Information -- Run-time and compile-time version checks.
=over
=item $version_code = Cairo->lib_version
=item $version_string = Cairo->lib_version_string
These two functions return the version of libcairo that the program is
currently running against.
=item $version_code = Cairo->LIB_VERSION
Returns the version of libcairo that Cairo was compiled against.
=item $version_code = Cairo->LIB_VERSION_ENCODE ($major, $minor, $micro)
=over
=item $major: integer
=item $minor: integer
=item $micro: integer
=back
Encodes the version C<$major.$minor.$micro> as an integer suitable for
comparison against C<< Cairo->lib_version >> and C<< Cairo->LIB_VERSION >>.
=back
=cut
# --------------------------------------------------------------------------- #
=head1 SEE ALSO
=over
=item L
Lists many available resources including tutorials and examples
=item L
Contains the reference manual
=back
=head1 AUTHORS
=over
=item Ross McFarland Erwmcfa1 at neces dot comE
=item Torsten Schoenfeld Ekaffeetisch at gmx dot deE
=back
=head1 COPYRIGHT
Copyright (C) 2004-2013 by the cairo perl team
=cut
Cairo-1.109/examples/pdf-tagged-text.pl 000755 001750 000024 00000016017 13757124331 020167 0 ustar 00brian staff 000000 000000 #! /usr/bin/perl
# Adapted and translated to Perl from the file test/pdf-tagged-test.c in the
# Cairo (version 1.17.3) source repository by Adrian Johnson .
use strict;
use warnings;
use Cairo;
use feature 'say';
# This test checks PDF with
# - tagged text
# - hyperlinks
# - document outline
# - metadata
# - thumbnails
# - page labels
use constant
{
FILENAME => 'pdf-tagged-text.pl.pdf',
PAGE_WIDTH => 595,
PAGE_HEIGHT => 842,
HEADING1_SIZE => 16,
HEADING2_SIZE => 14,
HEADING3_SIZE => 12,
TEXT_SIZE => 12,
HEADING_HEIGHT => 50,
MARGIN => 50,
};
my @contents =
(
[ 0, "Chapter 1", 1 ],
[ 1, "Section 1.1", 4 ],
[ 2, "Section 1.1.1", 3 ],
[ 1, "Section 1.2", 2 ],
[ 2, "Section 1.2.1", 4 ],
[ 2, "Section 1.2.2", 4 ],
[ 1, "Section 1.3", 2 ],
[ 0, "Chapter 2", 1 ],
[ 1, "Section 2.1", 4 ],
[ 2, "Section 2.1.1", 3 ],
[ 1, "Section 2.2", 2 ],
[ 2, "Section 2.2.1", 4 ],
[ 2, "Section 2.2.2", 4 ],
[ 1, "Section 2.3", 2 ],
[ 0, "Chapter 3", 1 ],
[ 1, "Section 3.1", 4 ],
[ 2, "Section 3.1.1", 3 ],
[ 1, "Section 3.2", 2 ],
[ 2, "Section 3.2.1", 4 ],
[ 2, "Section 3.2.2", 4 ],
[ 1, "Section 3.3", 2 ],
);
my @level_data =
(
[HEADING1_SIZE, 'H1', ['bold', 'open'],],
[HEADING2_SIZE, 'H2', [],],
[HEADING3_SIZE, 'H3', ['italic'],],
);
my @ipsum_lorem = split(' ', "Lorem ipsum dolor sit amet, consectetur adipiscing"
. " elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
. " Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi"
. " ut aliquip ex ea commodo consequat. Duis aute irure dolor in"
. " reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla"
. " pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa"
. " qui officia deserunt mollit anim id est laborum.");
my @roman_numerals = ( "i", "ii", "iii", "iv", "v", );
my @paragraph_text;
my $paragraph_height = 0;
my $line_height = 0;
my $y_pos = 0;
my @outline_parents;
my $page_num = 0;
sub layout_paragraph
{
my ($cr) = @_;
$cr->select_font_face('Serif', 'normal', 'normal');
$cr->set_font_size(TEXT_SIZE);
my $font_extents = $cr->font_extents();
$line_height = $$font_extents{height};
my $curr = $ipsum_lorem[0];
foreach (@ipsum_lorem[1..$#ipsum_lorem])
{
my $next = join(' ', $curr, $_);
my $text_extents = $cr->text_extents($next);
if ($$text_extents{width} + 2*MARGIN > PAGE_WIDTH)
{
push @paragraph_text, $curr;
$next = $_;
}
$curr = $next;
}
if ($curr ne '')
{
push @paragraph_text, $curr;
}
$paragraph_height = $line_height * (scalar @paragraph_text + 1);
}
sub draw_paragraph
{
my ($cr) = @_;
$cr->select_font_face('Serif', 'normal', 'normal');
$cr->set_font_size(TEXT_SIZE);
$cr->tag_begin('P', '');
foreach (@paragraph_text)
{
$cr->move_to(MARGIN, $y_pos);
$cr->show_text($_);
$y_pos += $line_height;
}
$cr->tag_end('P');
$y_pos += $line_height;
}
sub draw_page_num
{
my ($cr, $prefix, $num) = @_;
my $buf = ''
. (defined $prefix) ? $prefix : ''
. ($num) ? $num : '';
$cr->save();
$cr->select_font_face('Sans', 'normal', 'normal');
$cr->set_font_size(12);
$cr->move_to(PAGE_WIDTH/2, PAGE_HEIGHT - MARGIN);
$cr->show_text($buf);
$cr->restore();
$cr->get_target()->set_page_label($buf);
}
sub draw_contents
{
my ($cr, $section) = @_;
if ($y_pos + HEADING_HEIGHT + MARGIN > PAGE_HEIGHT)
{
$cr->show_page();
draw_page_num($cr, $roman_numerals[$page_num++], 0);
$y_pos = MARGIN;
}
$cr->move_to(MARGIN, $y_pos);
$cr->select_font_face('Sans', 'normal', 'normal');
$cr->set_font_size($level_data[$$section[0]]->[0]);
$cr->save();
$cr->set_source_rgb(0, 0, 1);
$cr->tag_begin('TOCI', '');
$cr->tag_begin('Reference', '');
$cr->tag_begin(Cairo::TAG_LINK, "dest='".$$section[1]."'");
$cr->show_text($$section[1]);
$cr->tag_end(Cairo::TAG_LINK);
$cr->tag_end('Reference');
$cr->tag_end('TOCI');
$cr->restore();
$y_pos += HEADING_HEIGHT;
}
sub draw_section
{
my ($cr, $section) = @_;
my $parent;
if ($$section[0] == 0)
{
$cr->show_page();
draw_page_num($cr, undef, $page_num++);
$y_pos = MARGIN;
$parent = $cr->get_target->OUTLINE_ROOT;
}
else
{
if ($y_pos + HEADING_HEIGHT + $paragraph_height + MARGIN > PAGE_HEIGHT)
{
$cr->show_page();
draw_page_num($cr, undef, $page_num++);
$y_pos = MARGIN;
}
$parent = $outline_parents[$$section[0]-1];
}
$cr->tag_begin('Sect', '');
$cr->select_font_face('Sans', 'normal', 'bold');
$cr->set_font_size($level_data[$$section[0]]->[0]);
$cr->move_to(MARGIN, $y_pos);
$cr->tag_begin($level_data[$$section[0]]->[1], '');
$cr->tag_begin(Cairo::TAG_DEST, "name='".$$section[1]."'");
$cr->show_text($$section[1]);
$cr->tag_end(Cairo::TAG_DEST);
$cr->tag_end($level_data[$$section[0]]->[1]);
$y_pos += HEADING_HEIGHT;
$outline_parents[$$section[0]] = $cr->get_target()->add_outline($parent, $$section[1], "dest='".$$section[1]."'", $level_data[$$section[0]]->[2]);
for (my $i=0; $i<$$section[2]; $i++)
{
if ($y_pos + $paragraph_height + MARGIN > PAGE_HEIGHT)
{
$cr->show_page();
draw_page_num($cr, undef, $page_num++);
$y_pos = MARGIN;
}
draw_paragraph($cr);
}
$cr->tag_end('Sect');
}
sub draw_cover
{
my ($cr) = @_;
$cr->select_font_face("Sans", 'normal', 'bold');
$cr->set_font_size(16);
$cr->move_to(PAGE_WIDTH/3, PAGE_HEIGHT/2);
$cr->tag_begin("Span", '');
$cr->show_text("PDF Features Test");
$cr->tag_end("Span");
draw_page_num($cr, "cover", 0);
}
sub create_document
{
my ($surface, $cr) = @_;
layout_paragraph($cr);
$surface->set_thumbnail_size(PAGE_WIDTH/10, PAGE_HEIGHT/10);
$surface->set_metadata('title', "PDF Features Test");
$surface->set_metadata('author', "cairo test suite");
$surface->set_metadata('subject', "cairo test");
$surface->set_metadata('keywords', "tags, links, outline, page labels, metadata, thumbnails");
$surface->set_metadata('creator', "pdf-features");
$surface->set_metadata('create-date', "2016-01-01T12:34:56+10:30");
$surface->set_metadata('mod-date', "2016-06-21T05:43:21Z");
$cr->tag_begin("Document", '');
draw_cover($cr);
$surface->add_outline($surface->OUTLINE_ROOT, 'Cover', 'page=1', ['bold']);
$cr->show_page();
$page_num = 0;
draw_page_num($cr, $roman_numerals[$page_num++], 0);
$y_pos = MARGIN;
$surface->add_outline($surface->OUTLINE_ROOT, "Contents", "dest='TOC'", ['bold']);
$cr->tag_begin(Cairo::TAG_DEST, "name='TOC' internal");
$cr->tag_begin("TOC", '');
foreach (@contents)
{
draw_contents($cr, $_);
}
$cr->tag_end("TOC");
$cr->tag_end(Cairo::TAG_DEST);
$page_num = 1;
foreach (@contents)
{
draw_section($cr, $_);
}
$cr->tag_end("Document");
}
my $surface = Cairo::PdfSurface->create(FILENAME, PAGE_WIDTH, PAGE_HEIGHT);
my $cr = Cairo::Context->create($surface);
create_document($surface, $cr);
my $status = $cr->status();
$cr = undef;
$surface->finish();
my $status2 = $surface->status();
if ($status ne 'success')
{
$status = $status2;
}
$surface = undef;
if ($status ne 'success')
{
say "Failed to create pdf surface: $status";
die;
}
0;
Cairo-1.109/examples/glyph-text.pl 000644 001750 000024 00000002405 11664366475 017315 0 ustar 00brian staff 000000 000000 #!/usr/bin/env perl
use strict;
use warnings;
use utf8;
use Cairo;
use constant
{
WIDTH => 250,
HEIGHT => 200,
NUM_GLYPHS => 10,
TEXT => 'abcdefghij',
};
my $surface = Cairo::PdfSurface->create ('glyph-text.pdf', WIDTH, HEIGHT);
my $cr = Cairo::Context->create ($surface);
$cr->select_font_face ('sans', 'normal', 'normal');
$cr->set_font_size (40);
my @glyphs = ();
my $dx = 0;
my $dy = 0;
foreach (0 .. NUM_GLYPHS - 1) {
# This selects the first few glyphs defined in the font,
# usually C<< !"#$%&'()* >>.
my $glyph = { index => $_ + 4, x => $dx, y => $dy };
my $extents = $cr->glyph_extents ($glyph);
$dx += $extents->{x_advance};
$dy += $extents->{y_advance};
push @glyphs, $glyph;
}
# One-to-one mapping between glyphs and bytes in a string. This relies on the
# utf8 represenation of the letters in TEXT being one byte long.
my @clusters = map { {num_bytes => 1, num_glyphs => 1} } (1 .. NUM_GLYPHS);
my $height = $cr->font_extents->{height};
# Display the glyphs normally
$cr->translate (0, $height);
$cr->show_glyphs (@glyphs);
# Display the glyphs such that when you select and copy them, you actually get
# reverse of TEXT, i.e. 'jihgfedcba'.
$cr->translate (0, $height);
$cr->show_text_glyphs (TEXT, \@glyphs, \@clusters, 'backward');
$cr->show_page;
Cairo-1.109/examples/png/ 000755 001750 000024 00000000000 14001743452 015414 5 ustar 00brian staff 000000 000000 Cairo-1.109/examples/twisted-text.pl 000644 001750 000024 00000020266 11664366475 017662 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
use strict;
use warnings;
use Glib qw(TRUE FALSE);
use Pango;
# This is a port of pango's cairotwisted example written by Behdad Esfahbod.
sub two_points_distance {
my ($a, $b) = @_;
my $dx = $b->[0] - $a->[0];
my $dy = $b->[1] - $a->[1];
return sqrt($dx * $dx + $dy * $dy);
}
sub parametrize_path {
my ($path) = @_;
my $current_point;
my @parametrization = ();
foreach (0 .. $#{$path}) {
my $data = $path->[$_];
$parametrization[$_] = 0.0;
if ($data->{type} eq "move-to") {
$current_point = $data->{points}[0];
}
elsif ($data->{type} eq "line-to") {
$parametrization[$_] = two_points_distance ($current_point, $data->{points}[0]);
$current_point = $data->{points}[0];
}
elsif ($data->{type} eq "curve-to") {
$parametrization[$_] = two_points_distance ($current_point, $data->{points}->[0]);
$parametrization[$_] += two_points_distance ($data->{points}[0], $data->{points}[1]);
$parametrization[$_] += two_points_distance ($data->{points}[1], $data->{points}[2]);
$current_point = $data->{points}[2];
}
}
return \@parametrization;
}
sub _fancy_cairo_stroke {
my ($cr, $preserve) = @_;
my $line_width = $cr->get_line_width;
my $path = $cr->copy_path;
$cr->new_path;
$cr->save;
$cr->set_line_width($line_width / 3);
$cr->set_dash(0, 10, 10);
foreach my $data (@{$path}) {
my @points = @{$data->{points}};
if ($data->{type} eq "move-to" ||
$data->{type} eq "line-to")
{
$cr->move_to ($points[0][0], $points[0][1]);
}
elsif ($data->{type} eq "curve-to") {
$cr->line_to ($points[0][0], $points[0][1]);
$cr->move_to ($points[1][0], $points[1][1]);
$cr->line_to ($points[2][0], $points[2][1]);
}
}
$cr->stroke;
$cr->restore;
$cr->save;
$cr->set_line_width ($line_width * 4);
$cr->set_line_cap ("round");
foreach my $data (@{$path}) {
my @points = @{$data->{points}};
if ($data->{type} eq "move-to") {
$cr->move_to ($points[0][0], $points[0][1]);
}
elsif ($data->{type} eq "line-to") {
$cr->rel_line_to (0, 0);
$cr->move_to ($points[0][0], $points[0][1]);
}
elsif ($data->{type} eq "curve-to") {
$cr->rel_line_to (0, 0);
$cr->move_to ($points[0][0], $points[0][1]);
$cr->rel_line_to (0, 0);
$cr->move_to ($points[1][0], $points[1][1]);
$cr->rel_line_to (0, 0);
$cr->move_to ($points[2][0], $points[2][1]);
}
elsif ($data->{type} eq "close-path") {
$cr->rel_line_to (0, 0);
}
}
$cr->rel_line_to (0, 0);
$cr->stroke;
$cr->restore;
foreach my $data (@{$path}) {
my @points = @{$data->{points}};
if ($data->{type} eq "move-to") {
$cr->move_to ($points[0][0], $points[0][1]);
}
elsif ($data->{type} eq "line-to") {
$cr->line_to ($points[0][0], $points[0][1]);
}
elsif ($data->{type} eq "curve-to") {
$cr->curve_to ($points[0][0], $points[0][1],
$points[1][0], $points[1][1],
$points[2][0], $points[2][1]);
}
elsif ($data->{type} eq "close-path") {
$cr->close_path;
}
}
$cr->stroke;
if ($preserve) {
$cr->append_path ($path);
}
}
sub fancy_cairo_stroke {
my ($cr) = @_;
_fancy_cairo_stroke ($cr, FALSE);
}
sub fancy_cairo_stroke_preserve {
my ($cr) = @_;
_fancy_cairo_stroke ($cr, TRUE);
}
sub transform_path {
my ($path, $f, $closure) = @_;
foreach my $data (@{$path}) {
if ($data->{type} eq "curve-to") {
$f->($closure, $data->{points}[2]);
$f->($closure, $data->{points}[1]);
$f->($closure, $data->{points}[0]);
}
elsif ($data->{type} eq "move-to" ||
$data->{type} eq "line-to")
{
$f->($closure, $data->{points}[0]);
}
}
}
sub point_on_path {
my ($param, $point) = @_;
my $oldy = $point->[1];
my $d = $point->[0];
my $path = $param->{path};
my $parametrization = $param->{parametrization};
my ($ratio, $dx, $dy);
my $data;
my $current_point = undef;
my $length = $#{$path};
my $i;
for ($i = 0; $i < $length && $d > $parametrization->[$i]; $i++) {
$d -= $parametrization->[$i];
$data = $path->[$i];
if ($data->{type} eq "move-to" ||
$data->{type} eq "line-to")
{
$current_point = $data->{points}[0];
}
elsif ($data->{type} eq "curve-to") {
$current_point = $data->{points}[2];
}
}
$data = $path->[$i];
if ($data->{type} eq "line-to") {
my $ratio = $d / $parametrization->[$i];
$point->[0] = $current_point->[0] * (1 - $ratio) + $data->{points}[0][0] * $ratio;
$point->[1] = $current_point->[1] * (1 - $ratio) + $data->{points}[0][1] * $ratio;
$dx = -($current_point->[0] - $data->{points}[0][0]);
$dy = -($current_point->[1] - $data->{points}[0][1]);
$d = $oldy;
$ratio = $d / $parametrization->[$i];
$point->[0] += -$dy * $ratio;
$point->[1] += $dx * $ratio;
}
elsif ($data->{type} eq "curve-to") {
$ratio = $d / $parametrization->[$i];
$point->[0] = $current_point->[0] * (1 - $ratio) * (1 - $ratio) * (1 - $ratio)
+ 3 * $data->{points}[0][0] * (1 - $ratio) * (1 - $ratio) * $ratio
+ 3 * $data->{points}[1][0] * (1 - $ratio) * $ratio * $ratio
+ 3 * $data->{points}[2][0] * $ratio * $ratio * $ratio;
$point->[1] = $current_point->[1] * (1 - $ratio) * (1 - $ratio) * (1 - $ratio)
+ 3 * $data->{points}[0][1] * (1 - $ratio) * (1 - $ratio) * $ratio
+ 3 * $data->{points}[1][1] * (1 - $ratio) * $ratio * $ratio
+ 3 * $data->{points}[2][1] * $ratio * $ratio * $ratio;
$dx =-3 * $current_point->[0] * (1 - $ratio) * (1 - $ratio)
+ 3 * $data->{points}[0][0] * (1 - 4 * $ratio + 3 * $ratio * $ratio)
+ 3 * $data->{points}[1][0] * ( 2 * $ratio - 3 * $ratio * $ratio)
+ 3 * $data->{points}[2][0] * $ratio * $ratio;
$dy =-3 * $current_point->[1] * (1 - $ratio) * (1 - $ratio)
+ 3 * $data->{points}[0][1] * (1 - 4 * $ratio + 3 * $ratio * $ratio)
+ 3 * $data->{points}[1][1] * ( 2 * $ratio - 3 * $ratio * $ratio)
+ 3 * $data->{points}[2][1] * $ratio * $ratio;
$d = $oldy;
$ratio = $d / sqrt ($dx * $dx + $dy * $dy);
$point->[0] += -$dy * $ratio;
$point->[1] += $dx * $ratio;
}
}
sub map_path_onto {
my ($cr, $path) = @_;
my $param = {
path => $path,
parametrization => parametrize_path ($path),
};
my $current_path = $cr->copy_path;
transform_path ($current_path, \&point_on_path, $param);
$cr->new_path;
$cr->append_path ($current_path);
}
sub draw_path {
my ($cr) = @_;
$cr->move_to (50, 700);
$cr->line_to (300, 750);
$cr->curve_to (550, 800, 900, 700, 900, 400);
$cr->curve_to (900, 0, 600, 300, 100, 100);
}
sub draw_text {
my ($cr) = @_;
my $font_options = Cairo::FontOptions->create;
$font_options->set_hint_style ("none");
$font_options->set_hint_metrics ("off");
$cr->set_font_options ($font_options);
my $layout = Pango::Cairo::create_layout ($cr);
my $desc = Pango::FontDescription->from_string ("Serif 72");
$layout->set_font_description ($desc);
$layout->set_text ("It was a dream... Oh Just a dream...");
my $line = $layout->get_line (0);
Pango::Cairo::layout_line_path ($cr, $line);
}
sub draw {
my ($cr) = @_;
# Decrease tolerance a bit, since it's going to be magnified
$cr->set_tolerance (0.05);
$cr->set_source_rgb (1.0, 0.0, 0.0);
draw_path ($cr);
fancy_cairo_stroke_preserve ($cr);
my $path = $cr->copy_path_flat;
$cr->new_path;
draw_text ($cr);
map_path_onto ($cr, $path);
$cr->set_source_rgba (0.3, 0.3, 1.0, 0.3);
$cr->fill_preserve;
$cr->set_source_rgb (0.1, 0.1, 0.1);
$cr->stroke;
}
{
if ($#ARGV != 0) {
warn "Usage: cairo-twisted-text.pl OUTPUT_FILENAME\n";
exit 1;
}
my $filename = $ARGV[0];
my $surface = Cairo::ImageSurface->create ("argb32", 500, 500);
my $cr = Cairo::Context->create ($surface);
$cr->translate (0, 50);
$cr->scale (0.5, 0.5);
$cr->set_source_rgb (1.0, 1.0, 1.0);
$cr->paint;
draw ($cr);
if ("success" ne $surface->write_to_png ($filename)) {
warn "Could not save png to '$filename'\n";
exit 1;
}
exit 0;
}
Cairo-1.109/examples/mime-unique-id.pl 000755 001750 000024 00000014525 13757124331 020032 0 ustar 00brian staff 000000 000000 #! /usr/bin/perl
# Adapted and translated to Perl from the test/mime-unique-id.c file in the
# Cairo (version 1.17.3) source repository.
# Check that source surfaces with same CAIRO_MIME_TYPE_UNIQUE_ID are
# embedded only once in PDF/PS.
#
# To exercise all the surface embedding code in PDF, four types of
# source surfaces are painted on each page, each with its own UNIQUE_ID:
# - an image surface
# - a recording surface with a jpeg mime attached
# - a bounded recording surface
# - an unbounded recording surface.
#
# Four pages are generated. Each source is clipped starting with the
# smallest area on the first page increasing to the unclipped size on
# the last page. This is to ensure the output does not embed the
# source clipped to a smaller size than used on subsequent pages.
use strict;
use warnings;
use Cairo;
use Fcntl;
use feature 'say';
use constant
{
NUM_PAGES => 4,
WIDTH => 275,
HEIGHT => 275,
RECORDING_SIZE => 800,
TILE_SIZE => 40,
PNG_FILENAME => 'romedalen.png',
JPG_FILENAME => 'romedalen.jpg',
OUTPUT_FILENAME => 'mime-unique-id.perl.pdf',
M_PI => 3.1415926,
};
sub create_image_surface
{
my $surface = Cairo::ImageSurface->create_from_png(PNG_FILENAME);
my $status = $surface->status();
if ($status ne 'success')
{
say $surface->status();
die;
}
$surface->set_mime_data($surface->MIME_TYPE_UNIQUE_ID, PNG_FILENAME);
$surface->set_mime_data($surface->MIME_TYPE_UNIQUE_ID, 'image');
return $surface;
}
sub create_recording_surface_with_mime_jpg
{
my $surface = Cairo::RecordingSurface->create('alpha', {x => 0, y => 0, width => 1, height => 1});
if ($surface->status() ne 'success')
{
say $surface->status();
die;
}
my ($FH, $want, $data);
unless (sysopen($FH, JPG_FILENAME, O_RDONLY|O_BINARY))
{
die;
}
$want = -s $FH;
$data = '';
while (1)
{
my $rc = sysread($FH, $data, $want, length($data));
die unless defined $rc;
last if $rc == 0;
$want -= $rc;
last if $want <= 0;
}
close($FH);
$surface->set_mime_data($surface->MIME_TYPE_JPEG, $data);
if ($surface->status() ne 'success')
{
say $surface->status();
die;
}
$surface->set_mime_data($surface->MIME_TYPE_UNIQUE_ID, 'jpeg');
if ($surface->status() ne 'success')
{
say $surface->status();
die;
}
return $surface;
}
sub draw_tile
{
my ($cr) = @_;
$cr->move_to(10+5, 10);
$cr->arc(10, 10, 5, 0, 2*M_PI);
$cr->close_path();
$cr->set_source_rgb(1, 0, 0);
$cr->fill();
$cr->move_to(30, 10-10*0.43);
$cr->line_to(25, 10+10*0.43);
$cr->line_to(35, 10+10*0.43);
$cr->close_path();
$cr->set_source_rgb(0, 1, 0);
$cr->fill();
$cr->rectangle(5, 25, 10, 10);
$cr->set_source_rgb(0, 0, 0);
$cr->fill();
$cr->save();
$cr->translate(30, 30);
$cr->rotate(M_PI/4.0);
$cr->rectangle(-5, -5, 10, 10);
$cr->set_source_rgb(1, 0, 1);
$cr->fill();
$cr->restore();
}
sub create_recording_surface
{
my ($bounded) = @_;
my ($surface, $start, $size);
if ($bounded)
{
$surface = Cairo::RecordingSurface->create('alpha', {x => 0, y => 0, width => RECORDING_SIZE, height => RECORDING_SIZE});
($start, $size) = (0, RECORDING_SIZE);
}
else
{
$surface = Cairo::RecordingSurface->create('alpha', undef);
($start, $size) = (RECORDING_SIZE/2, RECORDING_SIZE*2);
}
# Draw each tile instead of creating a cairo pattern to make size
# of the emitted recording as large as possible.
my ($cr) = Cairo::Context->create($surface);
$cr->set_source_rgb(1, 1, 0);
$cr->paint();
my $ctm = $cr->get_matrix();
for (my $y = $start; $y < $size; $y += TILE_SIZE)
{
for (my $x = $start; $x < $size; $x += TILE_SIZE)
{
draw_tile($cr);
$cr->translate(TILE_SIZE, 0);
}
$ctm->translate(0, TILE_SIZE);
$cr->set_matrix($ctm);
}
$cr = undef;
$surface->set_mime_data($surface->MIME_TYPE_UNIQUE_ID, $bounded ? 'recording bounded' : 'recording unbounded');
if ($surface->status() ne 'success')
{
say $surface->status();
die;
}
return $surface;
}
# Draw @source scaled to fit @rect and clipped to a rectangle
# @clip_margin units smaller on each side. @rect will be stroked
# with a solid line and the clip rect stroked with a dashed line.
sub draw_surface
{
my ($cr, $source, $rect, $clip_margin) = @_;
my ($width, $height);
my $type = $source->get_type();
if ($type eq 'image')
{
$width = $source->get_width();
$height = $source->get_height();
}
elsif (defined(my $extents = $source->get_extents()))
{
$width = $$extents{width};
$height = $$extents{height};
}
else
{
$width = RECORDING_SIZE;
$height = RECORDING_SIZE;
}
$cr->save();
$cr->rectangle($$rect{x}, $$rect{y}, $$rect{width}, $$rect{height});
$cr->stroke();
$cr->rectangle($$rect{x}+$clip_margin, $$rect{y}+$clip_margin, $$rect{width}-$clip_margin*2, $$rect{height}-$clip_margin*2);
$cr->set_dash(0, 2, 2);
$cr->stroke_preserve();
$cr->clip();
$cr->translate($$rect{x}, $$rect{y});
$cr->scale($$rect{width}/$width, $$rect{height}/$height);
$cr->set_source_surface($source, 0, 0);
$cr->paint();
$cr->restore();
}
sub draw_pages
{
my ($surface) = @_;
my $cr = Cairo::Context->create($surface);
# Draw the image and recording surface on each page. The sources
# are clipped starting with a small clip area on the first page
# and increasing to the source size on last page to ensure the
# embedded source is not clipped to the area used on the first
# page.
#
# The sources are created each time they are used to ensure
# CAIRO_MIME_TYPE_UNIQUE_ID is tested.
for (my $i=0; $i 25, y => 25, width => 100, height => 100,}, $clip_margin);
$source = undef;
$source = create_recording_surface_with_mime_jpg();
draw_surface($cr, $source, {x => 150, y => 25, width => 100, height => 100,}, $clip_margin);
$source = undef;
$source = create_recording_surface(1);
draw_surface($cr, $source, {x => 25, y => 150, width => 100, height => 100,}, $clip_margin);
$source = undef;
$source = create_recording_surface(0);
draw_surface($cr, $source, {x => 150, y => 150, width => 100, height => 100,}, $clip_margin);
$source = undef; # REQUIRED!
$cr->show_page();
}
$cr = undef;
}
my $surface = Cairo::PdfSurface->create(OUTPUT_FILENAME, WIDTH, HEIGHT);
if ($surface->status() ne 'success')
{
say $surface->status();
die;
}
draw_pages($surface);
$surface->finish();
0;
Cairo-1.109/examples/png-streams.pl 000644 001750 000024 00000001265 11664366475 017453 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
# $Id$
use strict;
use warnings;
use Cairo;
my $filename = $ARGV[0];
unless (-e $filename && -f $filename) {
die "`$filename´ doesn't seem to be a file";
}
open my $rfh, '<', $filename;
my $surface = Cairo::ImageSurface->create_from_png_stream (sub {
my ($closure, $length) = @_;
my $buffer;
if ($length != sysread ($rfh, $buffer, $length)) {
die 'read-error';
}
return $buffer;
});
warn "status: " . $surface->status;
close $rfh;
open my $wfh, '>', $filename . '.bak';
$surface->write_to_png_stream (sub {
my ($closure, $data) = @_;
if (!syswrite ($wfh, $data)) {
die 'write-error';
}
});
close $wfh;
warn "status: " . $surface->status;
Cairo-1.109/examples/subclassing.pl 000644 001750 000024 00000002074 11664366475 017527 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
use strict;
use warnings;
my $surface = Cairo::ImageSurface->create ('argb32', 1000, 1000);
my $context = CustomContext->create ($surface);
$context->draw_star;
$context->show_page;
$surface->write_to_png ($0 . '.png');
package CustomContext;
use strict;
use warnings;
use Cairo;
use Math::Trig qw/pi/;
use base qw/Cairo::Context/;
sub create {
my ($package, $surface) = @_;
my $self = $package->SUPER::create($surface);
return bless $self, $package;
}
sub draw_star {
my ($self) = @_;
my $width = $self->get_target()->get_width();
my $height = $self->get_target()->get_height();
$self->rectangle (0, 0, $width, $height);
$self->set_source_rgb (1, 1, 1);
$self->fill;
$self->save;
{
$self->set_source_rgba (0, 0, 0, 0.5);
$self->translate ($width / 2, $height / 2);
my $mx = $width / 3.0;
my $count = 100;
foreach (0 .. $count-1) {
$self->new_path;
$self->move_to (0, 0);
$self->rel_line_to (-$mx, 0);
$self->stroke;
$self->rotate ((pi() * 2) / $count);
}
}
$self->restore;
}
Cairo-1.109/examples/freetype-font.pl 000644 001750 000024 00000001371 11664366475 020000 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
use strict;
use warnings;
use Cairo;
unless (Cairo::HAS_FT_FONT && eval 'use Font::FreeType; 1;') {
die 'need Cairo with FreeType support and Font::FreeType';
}
# my $file = '/usr/share/fonts/truetype/ttf-inconsolata/Inconsolata.otf';
my $file = '/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf';
unless (-r $file) {
die 'Can\'t find font file';
}
my $ft_face = Font::FreeType->new->face ($file);
my $cr_face = Cairo::FtFontFace->create ($ft_face);
my $surface = Cairo::ImageSurface->create ('argb32', 200, 40);
my $cr = Cairo::Context->create ($surface);
$cr->set_font_face ($cr_face);
$cr->set_font_size (23);
$cr->move_to (20, 25);
$cr->show_text ('Hello, world!');
$cr->show_page;
$surface->write_to_png ('freetype-font.png');
Cairo-1.109/examples/simple.pl 000644 001750 000024 00000002370 11664366475 016502 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
#
# $Id$
#
use strict;
use warnings;
use Cairo;
use constant
{
IMG_WIDTH => 640,
IMG_HEIGHT => 480,
M_PI => 3.14159265,
};
die "png backend not supported" unless (Cairo::HAS_PNG_FUNCTIONS);
$0 =~ /(.*)\.pl/;
my $png = "$1.png";
my $surf = Cairo::ImageSurface->create ('argb32', IMG_WIDTH, IMG_HEIGHT);
my $cr = Cairo::Context->create ($surf);
$cr->rectangle (0, 0, IMG_WIDTH, IMG_HEIGHT);
$cr->set_source_rgba (1, 1, 1, 0.5);
$cr->fill;
# black
$cr->save;
$cr->set_source_rgba (0, 0, 0, 0.5);
$cr->translate (IMG_WIDTH / 2, IMG_HEIGHT - (IMG_HEIGHT / 4));
do_star ();
$cr->restore;
# red
$cr->save;
$cr->set_source_rgba (1, 0, 0, 0.5);
$cr->translate (IMG_WIDTH / 2, IMG_HEIGHT / 4);
do_star ();
$cr->restore;
# green
$cr->save;
$cr->set_source_rgba (0, 1, 0, 0.5);
$cr->translate (IMG_WIDTH / 4, IMG_HEIGHT / 2);
do_star ();
$cr->restore;
# blue
$cr->save;
$cr->set_source_rgba (0, 0, 1, 0.5);
$cr->translate (IMG_WIDTH - (IMG_WIDTH / 4), IMG_HEIGHT / 2);
do_star ();
$cr->restore;
$cr->show_page;
$surf->write_to_png ($png);
sub do_star
{
my $mx = IMG_WIDTH / 3.0;
my $count = 100;
foreach (0..$count-1)
{
$cr->new_path;
$cr->move_to (0, 0);
$cr->rel_line_to (-$mx, 0);
$cr->stroke;
$cr->rotate ((M_PI * 2) / $count);
}
}
Cairo-1.109/examples/png/bevels.pl 000644 001750 000024 00000013775 11664366475 017270 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
# This simple demo demonstrates how cairo may be used to draw
# old-fashioned widgets with bevels that depend on lines exactly
# 1-pixel wide.
#
# This demo is really only intended to demonstrate how someone might
# emulate antique graphics, and this style is really not recommended
# for future code. Some notes:
#
# 1) We're not going for pixel-perfect emulation of crusty graphics
# here. Notice that the checkmark is rendered nicely by cairo
# without jaggies.
#
# 2) The use of opaque highlight/lowlight colors here is particularly
# passe. A much more interesting approach would blend translucent
# colors over an arbitrary background.
#
# 3) This widget style is optimized for device-pixels. As such, it
# won't scale up very well, (except for integer scale
# factors). I'd be more interested to see future widget schemes
# that look good at all scales.
#
# One way to get better-looking graphics at all scales might be to
# introduce some device-pixel snapping into cairo for
# horizontal/vertical path components. Then, a lot of the 0.5
# adjustments could disappear from code like this, and then this code
# could become more scalable.
use strict;
use warnings;
use Cairo;
use constant
{
WIDTH => 100,
HEIGHT => 70,
M_PI => 4 * atan2(1, 1),
};
my $BG_COLOR = [ 0xd4, 0xd0, 0xc8 ];
my $HI_COLOR_1 = [ 0xff, 0xff, 0xff ];
my $HI_COLOR_2 = [ 0xd4, 0xd0, 0xc8 ];
my $LO_COLOR_1 = [ 0x80, 0x80, 0x80 ];
my $LO_COLOR_2 = [ 0x40, 0x40, 0x40 ];
my $BLACK = [ 0, 0, 0 ];
sub set_hex_color
{
my ($cr, $color) = @_;
$cr->set_source_rgb (
$color->[0] / 255.0,
$color->[1] / 255.0,
$color->[2] / 255.0);
}
sub bevel_box
{
my ($cr, $x, $y, $width, $height) = @_;
$cr->save;
$cr->set_line_width (1.0);
$cr->set_line_cap ('square');
# Fill and highlight
set_hex_color ($cr, $HI_COLOR_1);
$cr->rectangle ($x, $y, $width, $height);
$cr->fill;
# 2nd hightlight
set_hex_color ($cr, $HI_COLOR_2);
$cr->move_to ($x + 1.5, $y + $height - 1.5);
$cr->rel_line_to ($width - 3, 0);
$cr->rel_line_to (0, - ($height - 3));
$cr->stroke;
# 1st lowlight
set_hex_color ($cr, $LO_COLOR_1);
$cr->move_to ($x + 0.5, $y + $height - 1.5);
$cr->rel_line_to (0, - ($height - 2));
$cr->rel_line_to ($width - 2, 0);
$cr->stroke;
# 2nd lowlight
set_hex_color ($cr, $LO_COLOR_2);
$cr->move_to ($x + 1.5, $y + $height - 2.5);
$cr->rel_line_to (0, - ($height - 4));
$cr->rel_line_to ($width - 4, 0);
$cr->stroke;
$cr->restore;
}
sub bevel_circle
{
my ($cr, $x, $y, $width) = @_;
my $radius = ($width - 1)/2.0 - 0.5;
$cr->save;
$cr->set_line_width (1);
# Fill and highlight
set_hex_color ($cr, $HI_COLOR_1);
$cr->arc ($x+$radius+1.5, $y+$radius+1.5, $radius, 0, 2*M_PI);
$cr->fill;
# 2nd highlight
set_hex_color ($cr, $HI_COLOR_2);
$cr->arc ($x+$radius+0.5, $y+$radius+0.5, $radius, 0, 2*M_PI);
$cr->stroke;
# 1st lowlight
set_hex_color ($cr, $LO_COLOR_1);
$cr->arc ($x+$radius+0.5, $y+$radius+0.5, $radius, 3*M_PI/4, 7*M_PI/4);
$cr->stroke;
# 2nd lowlight
set_hex_color ($cr, $LO_COLOR_2);
$cr->arc ($x+$radius+1.5, $y+$radius+1.5, $radius, 3*M_PI/4, 7*M_PI/4);
$cr->stroke;
$cr->restore;
}
# Slightly smaller than specified to match interior size of bevel_box
sub flat_box
{
my ($cr, $x, $y, $width, $height) = @_;
$cr->save;
# Fill background
set_hex_color ($cr, $HI_COLOR_1);
$cr->rectangle ($x+1, $y+1, $width-2, $height-2);
$cr->fill;
# Stroke outline
$cr->set_line_width (1.0);
set_hex_color ($cr, $BLACK);
$cr->rectangle ($x+1.5, $y+1.5, $width-3, $height-3);
$cr->stroke;
$cr->restore;
}
sub flat_circle
{
my ($cr, $x, $y, $width) = @_;
my $radius = ($width - 1) / 2.0;
$cr->save;
# Fill background
set_hex_color ($cr, $HI_COLOR_1);
$cr->arc ($x+$radius+0.5, $y+$radius+0.5, $radius-1, 0, 2*M_PI);
$cr->fill;
# Stroke outline
$cr->set_line_width (1.0);
set_hex_color ($cr, $BLACK);
$cr->arc ($x+$radius+0.5, $y+$radius+0.5, $radius-1, 0, 2*M_PI);
$cr->stroke;
$cr->restore;
}
sub groovy_box
{
my ($cr, $x, $y, $width, $height) = @_;
$cr->save;
# Highlight
set_hex_color ($cr, $HI_COLOR_1);
$cr->set_line_width (2);
$cr->rectangle ($x+1, $y+1, $width-2, $height-2);
$cr->stroke;
# Lowlight
set_hex_color ($cr, $LO_COLOR_1);
$cr->set_line_width (1);
$cr->rectangle ($x+0.5, $y+0.5, $width-2, $height-2);
$cr->stroke;
$cr->restore;
}
use constant
{
CHECK_BOX_SIZE => 13,
};
sub check_box
{
my ($cr, $x, $y, $checked) = @_;
$cr->save;
bevel_box ($cr, $x, $y, CHECK_BOX_SIZE, CHECK_BOX_SIZE);
if ($checked) {
set_hex_color ($cr, $BLACK);
$cr->move_to ($x+3, $y+5);
$cr->rel_line_to (2.5, 2);
$cr->rel_line_to (4.5, -4);
$cr->rel_line_to (0, 3);
$cr->rel_line_to (-4.5, 4);
$cr->rel_line_to (-2.5, -2);
$cr->close_path;
$cr->fill;
}
$cr->restore;
}
use constant
{
RADIO_SIZE => CHECK_BOX_SIZE,
};
sub radio_button
{
my ($cr, $x, $y, $checked) = @_;
$cr->save;
bevel_circle ($cr, $x, $y, RADIO_SIZE);
if ($checked) {
set_hex_color ($cr, $BLACK);
$cr->arc (
$x + (RADIO_SIZE-1) / 2.0 + 0.5,
$y + (RADIO_SIZE-1) / 2.0 + 0.5,
(RADIO_SIZE-1) / 2.0 - 3.5,
0, 2 * M_PI);
$cr->fill;
}
$cr->restore;
}
sub draw_bevels
{
my ($cr, $width, $height) = @_;
my $check_room = ($width - 20) / 3;
my $check_pad = ($check_room - CHECK_BOX_SIZE) / 2;
groovy_box ($cr, 5, 5, $width - 10, $height - 10);
check_box ($cr, 10+$check_pad, 10+$check_pad, 0);
check_box ($cr, $check_room+10+$check_pad, 10+$check_pad, 1);
flat_box ($cr, 2 * $check_room+10+$check_pad, 10+$check_pad,
CHECK_BOX_SIZE, CHECK_BOX_SIZE);
radio_button ($cr, 10+$check_pad, $check_room+10+$check_pad, 0);
radio_button ($cr, $check_room+10+$check_pad, $check_room+10+$check_pad, 1);
flat_circle ($cr, 2 * $check_room+10+$check_pad, $check_room+10+$check_pad, CHECK_BOX_SIZE);
}
{
my $surface = Cairo::ImageSurface->create ('argb32', WIDTH, HEIGHT);
my $cr = Cairo::Context->create ($surface);
$cr->rectangle (0, 0, WIDTH, HEIGHT);
set_hex_color ($cr, $BG_COLOR);
$cr->fill;
draw_bevels ($cr, WIDTH, HEIGHT);
$surface->write_to_png ('bevels.png');
}
Cairo-1.109/examples/png/caps_joins.pl 000644 001750 000024 00000002645 11664366475 020132 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
use strict;
use warnings;
use Cairo;
use constant
{
WIDTH => 600,
HEIGHT => 600,
};
{
my $surf = Cairo::ImageSurface->create ('argb32', WIDTH, HEIGHT);
my $cr = Cairo::Context->create ($surf);
$0 =~ /(.*)\.pl/;
my $out = "$1.png";
$cr->rectangle (0, 0, WIDTH, HEIGHT);
$cr->set_source_rgb (1, 1, 1);
$cr->fill;
draw_caps_joins ($cr, WIDTH, HEIGHT);
$cr->show_page;
$surf->write_to_png ($out);
}
sub stroke_v_twice
{
my ($cr, $width, $height) = @_;
$cr->move_to (0, 0);
$cr->rel_line_to ($width / 2, $height / 2);
$cr->rel_line_to ($width / 2, - $height / 2);
$cr->save;
$cr->stroke;
$cr->restore;
$cr->save;
{
$cr->set_line_width (2.0);
$cr->set_line_cap ('butt');
$cr->set_source_rgb (1, 1, 1);
$cr->stroke;
}
$cr->restore;
$cr->new_path;
}
sub draw_caps_joins
{
my ($cr, $width, $height) = @_;
my $line_width = $height / 12 & (~1);
$cr->set_line_width ($line_width);
$cr->set_source_rgb (0, 0, 0);
$cr->translate ($line_width, $line_width);
$width -= 2 * $line_width;
$cr->set_line_join ('bevel');
$cr->set_line_cap ('butt');
stroke_v_twice ($cr, $width, $height);
$cr->translate (0, $height / 4 - $line_width);
$cr->set_line_join ('miter');
$cr->set_line_cap ('square');
stroke_v_twice ($cr, $width, $height);
$cr->translate (0, $height / 4 - $line_width);
$cr->set_line_join ('round');
$cr->set_line_cap ('round');
stroke_v_twice ($cr, $width, $height);
}
Cairo-1.109/examples/png/README 000644 001750 000024 00000000245 11664366475 016317 0 ustar 00brian staff 000000 000000 These files are ports of the cairo-demo/png examples as of 2006-05-28. This
stuff isn't done in perlish ways so you've been warned. You'll need png backend
support.
Cairo-1.109/examples/png/stars.pl 000644 001750 000024 00000002101 11664366475 017121 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
use strict;
use warnings;
use Cairo;
use constant
{
WIDTH => 600,
HEIGHT => 275,
M_PI => 3.14159265,
};
{
my $surf = Cairo::ImageSurface->create ('argb32', WIDTH, HEIGHT);
my $cr = Cairo::Context->create ($surf);
$0 =~ /(.*)\.pl/;
my $out = "$1.png";
$cr->rectangle (0, 0, WIDTH, HEIGHT);
$cr->set_source_rgb (1, 1, 1);
$cr->fill;
draw_stars ($cr, WIDTH, HEIGHT);
$cr->show_page;
$surf->write_to_png ($out);
}
sub star_path
{
my ($cr) = @_;
my $theta = 4 * M_PI / 5.0;
$cr->move_to (0, 0);
for (my $i = 0; $i < 4; $i++)
{
$cr->rel_line_to (1.0, 0);
$cr->rotate ($theta);
}
$cr->close_path;
}
sub draw_stars
{
my ($cr, $width, $height) = @_;
$cr->set_source_rgb (0, 0, 0);
$cr->save;
{
$cr->translate (5, $height / 2.6);
$cr->scale ($height, $height);
star_path ($cr);
$cr->set_fill_rule ('winding');
$cr->fill;
}
$cr->restore;
$cr->save;
{
$cr->translate ($width - $height - 5, $height / 2.6);
$cr->scale ($height, $height);
star_path ($cr);
$cr->set_fill_rule ('even-odd');
$cr->fill;
}
$cr->restore;
}
Cairo-1.109/examples/png/spline-pipeline.pl 000644 001750 000024 00000004723 11664366475 021076 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
use strict;
use warnings;
use Cairo;
use constant
{
LINE_WIDTH => 13,
};
sub spline_path
{
my ($cr) = @_;
$cr->save;
{
$cr->translate (-106.0988385, -235.84433);
$cr->move_to (49.517857, 235.84433);
$cr->curve_to (86.544809, 175.18401,
130.19603, 301.40165,
162.67982, 240.42946);
}
$cr->restore;
}
sub source_path
{
my ($cr) = @_;
spline_path ($cr);
$cr->set_line_width (1);
$cr->stroke;
}
sub stroke
{
my ($cr) = @_;
spline_path ($cr);
$cr->set_line_width (LINE_WIDTH);
$cr->stroke;
}
sub scale_both_set_line_width_stroke
{
my ($cr) = @_;
$cr->scale (0.5, 0.5);
spline_path ($cr);
$cr->set_line_width (LINE_WIDTH);
$cr->stroke;
}
sub scale_both_set_line_width_double_stroke
{
my ($cr) = @_;
$cr->scale (0.5, 0.5);
spline_path ($cr);
$cr->set_line_width (2 * LINE_WIDTH);
$cr->stroke;
}
sub save_scale_path_restore_set_line_width_stroke
{
my ($cr) = @_;
$cr->save;
{
$cr->scale (0.5, 1.0);
spline_path ($cr);
}
$cr->restore;
$cr->set_line_width (LINE_WIDTH);
$cr->stroke;
}
# XXX: Ouch. It looks like there's an API bug in the implemented semantics for
# cairo_set_line_width. I believe the following function
# (set_line_width_scale_path_stroke_BUGGY) should result in a figure identical
# to the version above it (save_scale_path_restore_set_line_width_stroke), but
# it's currently giving the same result as the one beloe
# (scale_path_set_line_width_stroke).
sub set_line_width_scale_path_stroke_BUGGY
{
my ($cr) = @_;
$cr->set_line_width (LINE_WIDTH);
$cr->scale (0.5, 1.0);
spline_path ($cr);
$cr->stroke;
}
sub scale_path_set_line_width_stroke
{
my ($cr) = @_;
$cr->scale (0.5, 1.0);
$cr->set_line_width (LINE_WIDTH);
spline_path ($cr);
$cr->stroke;
}
{
my @pipelines = (
\&source_path,
\&stroke,
\&scale_both_set_line_width_stroke,
\&scale_both_set_line_width_double_stroke,
\&save_scale_path_restore_set_line_width_stroke,
\&scale_path_set_line_width_stroke,
);
my $width = 140;
my $height = 68.833 * scalar @pipelines;
my $surface = Cairo::ImageSurface->create ('argb32', $width, $height);
my $cr = Cairo::Context->create ($surface);
foreach (0 .. $#pipelines) {
$cr->save;
{
$cr->translate ($width/2, ($_+0.5)*($height/scalar @pipelines));
$pipelines[$_]->($cr);
}
$cr->restore;
if ($cr->status ne 'success') {
warn "Cairo is unhappy after pipeline #$_: " . $cr->status . "\n";
exit 1;
}
}
$surface->write_to_png ('spline-pipeline.png');
}
Cairo-1.109/examples/png/splines_tolerance.pl 000644 001750 000024 00000001772 11664366475 021513 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
use strict;
use warnings;
use Cairo;
use constant
{
WIDTH => 600,
HEIGHT => 300,
};
{
my $surf = Cairo::ImageSurface->create ('argb32', WIDTH, HEIGHT);
my $cr = Cairo::Context->create ($surf);
$0 =~ /(.*)\.pl/;
my $out = "$1.png";
$cr->rectangle (0, 0, WIDTH, HEIGHT);
$cr->set_source_rgb (1, 1, 1);
$cr->fill;
draw_splines ($cr, WIDTH, HEIGHT);
$cr->show_page;
$surf->write_to_png ($out);
}
sub draw_spline
{
my ($cr, $height) = @_;
$cr->move_to (0, .1 * $height);
$height = .8 * $height;
$cr->rel_curve_to (-$height / 2, $height / 2, $height / 2, $height / 2,
0, $height);
$cr->stroke;
}
sub draw_splines
{
my ($cr, $width, $height) = @_;
my @tolerance = (.1, .5, 1, 5, 10);
my $line_width = .08 * $width;
my $gap = $width / 6;
$cr->set_source_rgb (0, 0, 0);
$cr->set_line_width ($line_width);
$cr->translate ($gap, 0);
for (my $i = 0; $i < 5; $i++)
{
$cr->set_tolerance ($tolerance[$i]);
draw_spline ($cr, $height);
$cr->translate ($gap, 0);
}
}
Cairo-1.109/examples/png/outline.pl 000644 001750 000024 00000004113 11664366475 017451 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
use strict;
use warnings;
use Cairo;
use constant
{
WIDTH => 750,
HEIGHT => 500,
};
{
my $surf = Cairo::ImageSurface->create ('argb32', WIDTH, HEIGHT);
my $cr = Cairo::Context->create ($surf);
$0 =~ /(.*)\.pl/;
my $out = "$1.png";
$cr->rectangle (0, 0, WIDTH, HEIGHT);
$cr->set_source_rgb (1, 1, 1);
$cr->fill;
draw_outlines ($cr, WIDTH, HEIGHT);
$cr->show_page;
$surf->write_to_png ($out);
}
sub create_gradient
{
my ($cr, $width, $height) = @_;
my $gradient = Cairo::LinearGradient->create (0, 0, $width, 0);
$gradient->add_color_stop_rgb (0.0, 0., 0., 0.);
$gradient->add_color_stop_rgb (0.5, 1., 1., 1.);
$gradient->add_color_stop_rgb (1.0, 0., 0., 0.);
return $gradient;
}
sub draw_outlines
{
my ($cr, $surface_width, $surface_height) = @_;
my $gradient;
my ($width, $height, $pad);
$width = $surface_width / 4.0;
$pad = ($surface_width - (3 * $width)) / 2.0;
$height = $surface_height;
$gradient = create_gradient ($cr, $width, $height);
$cr->set_source ($gradient);
draw_flat ($cr, $width, $height);
$cr->translate ($width + $pad, 0);
$cr->set_source ($gradient);
draw_tent ($cr, $width, $height);
$cr->translate ($width + $pad, 0);
$cr->set_source ($gradient);
draw_cylinder ($cr, $width, $height);
$cr->restore;
}
sub draw_flat
{
my ($cr, $width, $height) = @_;
my $hwidth = $width / 2.0;
$cr->rectangle (0, $hwidth, $width, $height - $hwidth);
$cr->fill;
}
sub draw_tent
{
my ($cr, $width, $height) = @_;
my $hwidth = $width / 2.0;
$cr->move_to ( 0, $hwidth);
$cr->rel_line_to ( $hwidth, -$hwidth);
$cr->rel_line_to ( $hwidth, $hwidth);
$cr->rel_line_to ( 0, $height - $hwidth);
$cr->rel_line_to (-$hwidth, -$hwidth);
$cr->rel_line_to (-$hwidth, $hwidth);
$cr->close_path;
$cr->fill;
}
sub draw_cylinder
{
my ($cr, $width, $height) = @_;
my $hwidth = $width / 2.0;
$cr->move_to (0, $hwidth);
$cr->rel_curve_to (0, -$hwidth, $width, -$hwidth, $width, 0);
$cr->rel_line_to (0, $height - $hwidth);
$cr->rel_curve_to (0, -$hwidth, -$width, -$hwidth, -$width, 0);
$cr->close_path;
$cr->fill;
}
Cairo-1.109/examples/png/text.pl 000644 001750 000024 00000006177 11747045545 016764 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
use strict;
use warnings;
use utf8;
use Cairo;
use constant
{
WIDTH => 450,
HEIGHT => 600,
TEXT => 'hëllø, wôrld',
NUM_GLYPHS => 10,
M_PI => 4 * atan2(1, 1),
};
sub box_text
{
my ($cr, $utf8, $x, $y) = @_;
$cr->save;
my $extents = $cr->text_extents ($utf8);
my $line_width = $cr->get_line_width;
$cr->rectangle ($x + $extents->{x_bearing} - $line_width,
$y + $extents->{y_bearing} - $line_width,
$extents->{width} + 2 * $line_width,
$extents->{height} + 2 *$line_width);
$cr->stroke;
$cr->move_to ($x, $y);
$cr->show_text ($utf8);
$cr->move_to ($x, $y);
$cr->text_path ($utf8);
$cr->set_source_rgb (1, 0, 0);
$cr->set_line_width (1.0);
$cr->stroke;
$cr->restore;
}
sub box_glyphs
{
my ($cr, $x, $y, @glyphs) = @_;
$cr->save;
my $extents = $cr->glyph_extents (@glyphs);
my $line_width = $cr->get_line_width;
$cr->rectangle ($x + $extents->{x_bearing} - $line_width,
$y + $extents->{y_bearing} - $line_width,
$extents->{width} + 2 * $line_width,
$extents->{height} + 2 * $line_width);
$cr->stroke;
foreach my $glyph (@glyphs) {
$glyph->{x} += $x;
$glyph->{y} += $y;
}
$cr->show_glyphs (@glyphs);
$cr->glyph_path (@glyphs);
$cr->set_source_rgb (1, 0, 0);
$cr->set_line_width (1.0);
$cr->stroke;
foreach my $glyph (@glyphs) {
$glyph->{x} -= $x;
$glyph->{y} -= $y;
}
$cr->restore;
}
{
my $surface = Cairo::ImageSurface->create ('argb32', WIDTH, HEIGHT);
my $cr = Cairo::Context->create ($surface);
$cr->set_source_rgb (0, 0, 0);
$cr->set_line_width (2.0);
$cr->save;
$cr->rectangle (0, 0, WIDTH, HEIGHT);
$cr->set_source_rgba (0, 0, 0, 0);
$cr->set_operator ('source');
$cr->fill;
$cr->restore;
$cr->select_font_face ('sans', 'normal', 'normal');
$cr->set_font_size (40);
if (1) {
my $matrix = Cairo::Matrix->init_scale (40, -40);
$cr->set_font_matrix ($matrix);
$cr->scale (1, -1);
$cr->translate (0, - HEIGHT);
}
my $font_extents = $cr->font_extents;
my $height = $font_extents->{height};
my @glyphs = ();
my $dx = 0;
my $dy = 0;
foreach (0 .. NUM_GLYPHS - 1) {
my $glyph = { index => $_ + 4, x => $dx, y => $dy };
my $extents = $cr->glyph_extents ($glyph);
$dx += $extents->{x_advance};
$dy += $extents->{y_advance};
push @glyphs, $glyph;
}
box_text ($cr, TEXT, 10, $height);
$cr->translate (0, $height);
$cr->save;
{
$cr->translate (10, $height);
$cr->rotate (10 * M_PI / 180);
box_text ($cr, TEXT, 0, 0);
}
$cr->restore;
$cr->translate (0, 2 * $height);
$cr->save;
{
my $matrix = Cairo::Matrix->init_identity;
$matrix->scale (40, -40);
$matrix->rotate (-10 * M_PI / 180);
$cr->set_font_matrix ($matrix);
box_text ($cr, TEXT, 10, $height);
}
$cr->restore;
$cr->translate (0, 2 * $height);
box_glyphs ($cr, 10, $height, @glyphs);
$cr->translate (10, 2 * $height);
$cr->save;
{
$cr->rotate (10 * M_PI / 180);
box_glyphs ($cr, 0, 0, @glyphs);
}
$cr->restore;
$cr->translate (0, $height);
foreach (0 .. NUM_GLYPHS - 1) {
$glyphs[$_]->{y} += $_ * 5;
}
box_glyphs ($cr, 10, $height, @glyphs);
$surface->write_to_png ('text.png');
}
Cairo-1.109/examples/png/hering.pl 000644 001750 000024 00000002227 11664366475 017252 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
use strict;
use warnings;
use Cairo;
use constant
{
WIDTH => 300,
HEIGHT => 600,
LINES => 32,
M_PI_2 => 3.14159265 / 2.0,
};
use constant
{
MAX_THETA => (.80 * M_PI_2),
};
use constant
{
THETA_INC => (2.0 * MAX_THETA / (LINES-1)),
};
{
my $surf = Cairo::ImageSurface->create ('argb32', WIDTH, HEIGHT);
my $cr = Cairo::Context->create ($surf);
$0 =~ /(.*)\.pl/;
my $out = "$1.png";
$cr->rectangle (0, 0, WIDTH, HEIGHT);
$cr->set_source_rgb (1, 1, 1);
$cr->fill;
draw_hering ($cr, WIDTH, HEIGHT);
$cr->show_page;
$surf->write_to_png ($out);
}
sub draw_hering
{
my ($cr, $width, $height) = @_;
$cr->set_source_rgb (0, 0, 0);
$cr->set_line_width (2.0);
$cr->save;
{
$cr->translate ($width / 2, $height / 2);
$cr->rotate (MAX_THETA);
for (my $i=0; $i < LINES; $i++)
{
$cr->move_to (-2 * $width, 0);
$cr->line_to (2 * $width, 0);
$cr->stroke;
$cr->rotate (- THETA_INC);
}
}
$cr->restore;
$cr->set_line_width (6);
$cr->set_source_rgb (1, 0, 0);
$cr->move_to ($width / 4, 0);
$cr->rel_line_to (0, $height);
$cr->stroke;
$cr->move_to (3 * $width / 4, 0);
$cr->rel_line_to (0, $height);
$cr->stroke;
}
Cairo-1.109/examples/png/text-rotate.pl 000644 001750 000024 00000003547 11664366475 020264 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
use strict;
use warnings;
use Cairo;
use constant
{
WIDTH => 450,
HEIGHT => 900,
NUM_STRINGS => 3,
M_PI => 4 * atan2(1, 1),
};
{
my $surface = Cairo::ImageSurface->create ('argb32', WIDTH, HEIGHT);
my $cr = Cairo::Context->create ($surface);
$cr->set_source_rgb (0.0, 0.0, 0.0);
$cr->translate (40, 40);
$cr->select_font_face ('mono', 'normal', 'normal');
$cr->set_font_size (12);
$cr->show_text ('+CTM rotation');
$cr->save;
$cr->select_font_face ('serif', 'normal', 'normal');
$cr->set_font_size (40);
for (my $i = 0; $i < NUM_STRINGS; $i++) {
my $angle = $i * 0.5 * M_PI / (NUM_STRINGS - 1);
$cr->save;
$cr->rotate ($angle);
$cr->move_to (100, 0);
$cr->show_text ("Text");
$cr->restore;
}
$cr->restore;
$cr->translate (0, HEIGHT / 3);
$cr->move_to (0, 0);
$cr->show_text ('+CTM rotation');
$cr->rel_move_to (0, 12);
$cr->show_text ('-font rotation');
$cr->save;
$cr->select_font_face ('serif', 'normal', 'normal');
$cr->set_font_size (40);
for (my $i = 0; $i < NUM_STRINGS; $i++) {
my $angle = $i * 0.5 * M_PI / (NUM_STRINGS - 1);
$cr->save;
$cr->rotate ($angle);
my $matrix = Cairo::Matrix->init_identity;
$matrix->scale (40, 40);
$matrix->rotate (-$angle);
$cr->set_font_matrix ($matrix);
$cr->move_to (100, 0);
$cr->show_text ('Text');
$cr->restore;
}
$cr->restore;
$cr->translate (0, HEIGHT / 3);
$cr->move_to (0, 0);
$cr->show_text ('+CTM rotation');
$cr->rel_move_to (0, 12);
$cr->show_text ('-CTM rotation');
$cr->save;
$cr->select_font_face ('serif', 'normal', 'normal');
$cr->set_font_size (40);
for (my $i = 0; $i < NUM_STRINGS; $i++) {
my $angle = $i * 0.5 * M_PI / (NUM_STRINGS - 1);
$cr->save;
$cr->rotate ($angle);
$cr->move_to (100, 0);
$cr->rotate (-$angle);
$cr->show_text ('Text');
$cr->restore;
}
$cr->restore;
$surface->write_to_png ('text-rotate.png');
}
Cairo-1.109/examples/png/star_and_ring.pl 000644 001750 000024 00000011200 11664366475 020577 0 ustar 00brian staff 000000 000000 #!/usr/bin/env perl
# This a Perl port of the C example cairo-demo/png/star_and_ring.c. Original
# copyright:
# Copyright © 2005 Red Hat, Inc.
#
# Permission to use, copy, modify, distribute, and sell this software
# and its documentation for any purpose is hereby granted without
# fee, provided that the above copyright notice appear in all copies
# and that both that copyright notice and this permission notice
# appear in supporting documentation, and that the name of
# Red Hat, Inc. not be used in advertising or publicity pertaining to
# distribution of the software without specific, written prior
# permission. Red Hat, Inc. makes no representations about the
# suitability of this software for any purpose. It is provided "as
# is" without express or implied warranty.
#
# RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
# IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# Author: Carl D. Worth
use strict;
use warnings;
use Cairo;
use constant {
WIDTH => 600,
HEIGHT => 600,
};
sub ring_path {
my ($cr) = @_;
$cr->move_to (200.86568, 667.80795);
$cr->curve_to (110.32266, 562.62134,
122.22863, 403.77940,
227.41524, 313.23637);
$cr->curve_to (332.60185, 222.69334,
491.42341, 234.57563,
581.96644, 339.76224);
$cr->curve_to (672.50948, 444.94884,
660.64756, 603.79410,
555.46095, 694.33712);
$cr->curve_to (450.27436, 784.88016,
291.40871, 772.99456,
200.86568, 667.80795);
$cr->close_path;
$cr->move_to (272.14411, 365.19927);
$cr->curve_to (195.64476, 431.04875,
186.97911, 546.57972,
252.82859, 623.07908);
$cr->curve_to (318.67807, 699.57844,
434.23272, 708.22370,
510.73208, 642.37422);
$cr->curve_to (587.23144, 576.52474,
595.85301, 460.99047,
530.00354, 384.49112);
$cr->curve_to (464.15406, 307.99176,
348.64347, 299.34979,
272.14411, 365.19927);
$cr->close_path;
}
sub star_path {
my ($cr) = @_;
my $matrix = Cairo::Matrix->init (0.647919, -0.761710,
0.761710, 0.647919,
-208.7977, 462.0608);
$cr->transform ($matrix);
$cr->move_to (505.80857, 746.23606);
$cr->line_to (335.06870, 555.86488);
$cr->line_to (91.840384, 635.31360);
$cr->line_to (282.21157, 464.57374);
$cr->line_to (202.76285, 221.34542);
$cr->line_to (373.50271, 411.71660);
$cr->line_to (616.73103, 332.26788);
$cr->line_to (426.35984, 503.00775);
$cr->line_to (505.80857, 746.23606);
$cr->close_path;
}
sub fill_ring {
my ($cr) = @_;
$cr->save;
$cr->translate (-90, -205);
ring_path ($cr);
$cr->set_source_rgba (1.0, 0.0, 0.0, 0.75);
$cr->fill;
$cr->restore;
}
sub fill_star {
my ($cr) = @_;
$cr->save;
$cr->translate (-90, -205);
star_path ($cr);
$cr->set_source_rgba (0.0, 0.0, 0xae / 0xff, 0.55135137);
$cr->fill;
$cr->restore;
}
sub clip_to_top_and_bottom {
my ($cr, $width, $height) = @_;
$cr->move_to (0, 0);
$cr->line_to ($width, 0);
$cr->line_to (0, $height);
$cr->line_to ($width, $height);
$cr->close_path;
$cr->clip;
$cr->new_path;
}
sub clip_to_left_and_right {
my ($cr, $width, $height) = @_;
$cr->move_to (0, 0);
$cr->line_to (0, $height);
$cr->line_to ($width, 0);
$cr->line_to ($width, $height);
$cr->close_path;
$cr->clip;
$cr->new_path;
}
{
my $result = Cairo::ImageSurface->create ('argb32', WIDTH, HEIGHT);
my $ring_over_star = Cairo::ImageSurface->create ('argb32', WIDTH, HEIGHT);
my $star_over_ring = Cairo::ImageSurface->create ('argb32', WIDTH, HEIGHT);
my $cr = Cairo::Context->create ($result);
{
my $cr_ros = Cairo::Context->create ($ring_over_star);
clip_to_top_and_bottom ($cr_ros, WIDTH, HEIGHT);
fill_star ($cr_ros);
fill_ring ($cr_ros);
}
{
my $cr_sor = Cairo::Context->create ($star_over_ring);
clip_to_left_and_right ($cr_sor, WIDTH, HEIGHT);
fill_ring ($cr_sor);
fill_star ($cr_sor);
}
$cr->set_operator ('add');
$cr->set_source_surface ($ring_over_star, 0, 0);
$cr->paint;
$cr->set_source_surface ($star_over_ring, 0, 0);
$cr->paint;
$result->write_to_png ("star_and_ring.png");
}
Cairo-1.109/examples/png/spiral.pl 000644 001750 000024 00000001577 11664366475 017277 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
use strict;
use warnings;
use Cairo;
use constant
{
WIDTH => 600,
HEIGHT => 600,
};
{
my $surf = Cairo::ImageSurface->create ('argb32', WIDTH, HEIGHT);
my $cr = Cairo::Context->create ($surf);
$0 =~ /(.*)\.pl/;
my $out = "$1.png";
$cr->rectangle (0, 0, WIDTH, HEIGHT);
$cr->set_source_rgb (1, 1, 1);
$cr->fill;
draw_spiral ($cr, WIDTH, HEIGHT);
$cr->show_page;
$surf->write_to_png ($out);
}
sub draw_spiral
{
my ($cr, $width, $height) = @_;
my $wd = .02 * $width;
my $hd = .02 * $height;
$width -= 2;
$height -= 2;
$cr->move_to ($width + 1, 1 - $hd);
for (my $i=0; $i < 9; $i++)
{
$cr->rel_line_to (0, $height - $hd * (2 * $i - 1));
$cr->rel_line_to (- ($width - $wd * (2 * $i)), 0);
$cr->rel_line_to (0, - ($height - $hd * (2 * $i)));
$cr->rel_line_to ($width - $wd * (2 * $i + 1), 0);
}
$cr->set_source_rgb (0, 0, 1);
$cr->stroke;
}
Cairo-1.109/examples/png/snapping.pl 000644 001750 000024 00000022125 11664366475 017614 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
# This is a Perl port of the C program cairo-demo/png/snapping.c. Original
# copyright:
# Copyright (c) 2004 Red Hat, Inc.
#
# Permission to use, copy, modify, distribute, and sell this software
# and its documentation for any purpose is hereby granted without
# fee, provided that the above copyright notice appear in all copies
# and that both that copyright notice and this permission notice
# appear in supporting documentation, and that the name of
# Red Hat, Inc. not be used in advertising or publicity pertaining to
# distribution of the software without specific, written prior
# permission. Red Hat, Inc. makes no representations about the
# suitability of this software for any purpose. It is provided "as
# is" without express or implied warranty.
#
# RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
# FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
# RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
# IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# Author: Carl D. Worth
use strict;
use warnings;
use Cairo;
use POSIX qw(floor);
# This demo demonstrates how to perform device-pixel snapping for
# horizontal and vertically aligned strokes and fills. The technique
# used here is designed to work with any stroke width as well as any
# scale factor or translation amount in the current transformation.
# The code here may not provide good results for curved objects or
# when the transformation includes rotation and or shear components.
#
# The output includes four groups of nested boxes. The top two groups
# consists of 5 filled boxes, alternating between black and
# white. The bottom two groups show 5 white stroked boxes. Within
# each group, the path for each box is constructed the same way, but
# with a different transform. For the two groups on the right, all
# coordinates in the path are snapped before drawing so that the
# boundary of each shape will align properly with the device pixel
# grid.
use constant
{
WIDTH => 175,
HEIGHT => 175,
};
# These snapping functions are designed to work properly with a
# matrix that has only scale and translate components. I make no
# guarantees about how they will behave under more interesting
# transformations (such as rotation or shear).
# Snap the given coordinate so that it is on an integer coordinate of
# the device pixel grid. This is the appropriate snapping to use for
# horizontal/vertical portions of paths to be filled.
sub snap_point_for_fill
{
my ($cr, $x, $y) = @_;
# Convert to device space, round, then convert back to user space.
($x, $y) = $cr->user_to_device ($x, $y);
$x = floor ($x + 0.5);
$y = floor ($y + 0.5);
($x, $y) = $cr->device_to_user ($x, $y);
return ($x, $y);
}
# Snap the given path coordinate as appropriate for a path to be
# stroked. This snapping is dependent on the current line width, so
# it should be called when the line width is set to the value that
# will be used for the stroke.
#
# The snapping is performed so that the stroke boundary of horizontal
# and vertical portions will lie precisely between device pixels. If
# the device-space line width is not an integer, then only one side
# of the path will be properly aligned. The snap_line_width function
# below can be used to constrain the line width to be an integer in
# device space.
sub snap_point_for_stroke
{
my ($cr, $x, $y) = @_;
# Round in device space after adding the fractional portion of
# one-half the (device space) line width.
my $x_width_dev_2 = $cr->get_line_width;
my $y_width_dev_2 = $cr->get_line_width;
($x_width_dev_2, $y_width_dev_2) =
$cr->user_to_device_distance ($x_width_dev_2, $y_width_dev_2);
$x_width_dev_2 *= 0.5;
$y_width_dev_2 *= 0.5;
my $x_offset = $x_width_dev_2 - int $x_width_dev_2;
my $y_offset = $y_width_dev_2 - int $y_width_dev_2;
($x, $y) = $cr->user_to_device ($x, $y);
$x = floor ($x + $x_offset + 0.5);
$y = floor ($y + $y_offset + 0.5);
$x -= $x_offset;
$y -= $y_offset;
($x, $y) = $cr->device_to_user ($x, $y);
return ($x, $y);
}
# Snap the line width so that it is an integer number of device
# pixels. Cairo currently only supports symmetrical pens, so if the
# current transformation has non-uniform scaling in X and Y, we won't
# be able to satisfy the constraint in both dimensions. So, this
# function examines both directions and snaps to the dimension that
# has the larger error.
sub snap_line_width
{
my ($cr) = @_;
my $x_width = $cr->get_line_width;
my $y_width = $cr->get_line_width;
($x_width, $y_width) = $cr->user_to_device_distance ($x_width, $y_width);
# If the line width is less than 1 then it will round to 0 and
# disappear. Instead, we clamp it to 1.0, but we must preserve
# its sign for the case of a reflecting transformation.
my $x_width_snapped = floor ($x_width + 0.5);
if (abs ($x_width_snapped) < 1.0) {
$x_width_snapped = $x_width > 0 ? 1.0 : -1.0;
}
my $y_width_snapped = floor ($y_width + 0.5);
if (abs ($y_width_snapped) < 1.0) {
$y_width_snapped = $y_width > 0 ? 1.0 : -1.0;
}
my $x_error = abs ($x_width - $x_width_snapped);
my $y_error = abs ($y_width - $y_width_snapped);
($x_width_snapped, $y_width_snapped) =
$cr->device_to_user_distance
($x_width_snapped, $y_width_snapped);
$cr->set_line_width
($x_error > $y_error ? $x_width_snapped : $y_width_snapped);
}
sub snap_point
{
my ($spc, $x, $y) = @_;
return $spc->{fill}
? snap_point_for_fill ($spc->{cr}, $x, $y)
: snap_point_for_stroke ($spc->{cr}, $x, $y);
}
sub spc_new_path_perhaps
{
my ($spc) = @_;
if ($spc->{first}) {
$spc->{cr}->new_path;
$spc->{first} = 0;
}
}
sub spc_move_to
{
my ($spc, $x, $y) = @_;
spc_new_path_perhaps ($spc);
($x, $y) = snap_point ($spc, $x, $y);
$spc->{cr}->move_to ($x, $y);
}
sub spc_line_to
{
my ($spc, $x, $y) = @_;
spc_new_path_perhaps ($spc);
($x, $y) = snap_point ($spc, $x, $y);
$spc->{cr}->line_to ($x, $y);
}
sub spc_curve_to
{
my ($spc, $x1, $y1, $x2, $y2, $x3, $y3) = @_;
spc_new_path_perhaps ($spc);
($x1, $y1) = snap_point ($spc, $x1, $y1);
($x2, $y2) = snap_point ($spc, $x2, $y2);
($x3, $y3) = snap_point ($spc, $x3, $y3);
$spc->{cr}->curve_to ($x1, $y1, $x2, $y2, $x3, $y3);
}
sub spc_close_path
{
my ($spc) = @_;
spc_new_path_perhaps ($spc);
$spc->{cr}->close_path;
}
sub snap_path_for_fill
{
my ($cr) = @_;
my $spc = {
first => 1,
fill => 1,
cr => $cr,
};
my $path = $cr->copy_path;
use Data::Dumper;
foreach (@{$path}) {
if ($_->{type} eq 'move-to') {
spc_move_to ($spc, @{$_->{points}->[0]});
}
elsif ($_->{type} eq 'line-to') {
spc_line_to ($spc, @{$_->{points}->[0]});
}
elsif ($_->{type} eq 'curve-to') {
spc_curve_to ($spc, @{$_->{points}->[0]},
@{$_->{points}->[1]},
@{$_->{points}->[2]});
}
else {
spc_close_path ($spc);
}
}
}
sub snap_path_for_stroke
{
my ($cr) = @_;
my $spc = {
first => 1,
fill => 0,
cr => $cr,
};
snap_line_width ($cr);
my $path = $cr->copy_path;
use Data::Dumper;
foreach (@{$path}) {
if ($_->{type} eq 'move-to') {
spc_move_to ($spc, @{$_->{points}->[0]});
}
elsif ($_->{type} eq 'line-to') {
spc_line_to ($spc, @{$_->{points}->[0]});
}
elsif ($_->{type} eq 'curve-to') {
spc_curve_to ($spc, @{$_->{points}->[0]},
@{$_->{points}->[1]},
@{$_->{points}->[2]});
}
else {
spc_close_path ($spc);
}
}
}
use constant {
NUM_BOXES => 5,
BOX_WIDTH => 13,
# We need non-integer scale factors to demonstrate anything
# interesting.
SCALE_TWEAK => 1.11,
};
sub draw_nested
{
my ($cr, $style, $snapping) = @_;
my $offset = SCALE_TWEAK * BOX_WIDTH / 2.0;
$cr->save;
$cr->set_line_width (1.0);
foreach (0 .. NUM_BOXES - 1) {
my $scale = SCALE_TWEAK * (NUM_BOXES - $_);
$cr->save;
{
$cr->scale ($scale, $scale);
$cr->rectangle (0, 0, BOX_WIDTH, BOX_WIDTH);
if ($style eq 'nested-fills') {
if ($snapping eq 'snapping') {
snap_path_for_fill ($cr);
}
if ($_ % 2 == 0) {
$cr->set_source_rgb (1, 1, 1);
} else {
$cr->set_source_rgb (0, 0, 0);
}
$cr->fill;
} else {
if ($snapping eq 'snapping') {
snap_path_for_stroke ($cr);
}
$cr->set_source_rgb (1, 1, 1);
$cr->stroke;
}
}
$cr->restore;
$cr->translate ($offset, $offset);
}
$cr->restore;
}
sub draw
{
my ($cr, $width, $height) = @_;
$cr->translate (6, 6);
draw_nested ($cr, 'nested-fills', 'no-snapping');
$cr->translate ($width / 2, 0);
draw_nested ($cr, 'nested-fills', 'snapping');
$cr->translate (-$width / 2, $height / 2);
draw_nested ($cr, 'nested-strokes', 'no-snapping');
$cr->translate ($width / 2, 0);
draw_nested ($cr, 'nested-strokes', 'snapping');
}
{
my $surface = Cairo::ImageSurface->create ('argb32', WIDTH, HEIGHT);
my $cr = Cairo::Context->create ($surface);
$cr->rectangle (0, 0, WIDTH, HEIGHT);
$cr->set_source_rgb (0, 0, 0);
$cr->fill;
draw ($cr, WIDTH, HEIGHT);
$surface->write_to_png ('snapping.png');
}
Cairo-1.109/t/CairoMatrix.t 000644 001750 000024 00000002037 11664366475 015710 0 ustar 00brian staff 000000 000000 #
# Copyright (c) 2004-2005 by the cairo perl team (see the file README)
#
# Licensed under the LGPL, see LICENSE file for more information.
#
# $Id$
#
use strict;
use warnings;
use Test::More tests => 10;
use Cairo;
my $matrix = Cairo::Matrix->init (1, 2, 3, 4, 5, 6);
isa_ok ($matrix, 'Cairo::Matrix');
$matrix = Cairo::Matrix->init_identity;
isa_ok ($matrix, 'Cairo::Matrix');
$matrix = Cairo::Matrix->init_translate (1, 2);
isa_ok ($matrix, 'Cairo::Matrix');
$matrix = Cairo::Matrix->init_scale (3, 4);
isa_ok ($matrix, 'Cairo::Matrix');
$matrix = Cairo::Matrix->init_rotate (3.1415);
isa_ok ($matrix, 'Cairo::Matrix');
eval
{
$matrix->translate (1, 2);
$matrix->scale (3, 4);
$matrix->rotate (3.1415);
};
is ($@, '', 'translate, scale, rotate');
is ($matrix->invert, 'success');
my $id = Cairo::Matrix->init_identity;
isa_ok ($matrix->multiply ($id), 'Cairo::Matrix');
is_deeply ([$id->transform_distance (1, 1)], [1, 1],
'$id->transform_distance');
is_deeply ([$id->transform_point (1, 1)], [1, 1],
'$id->transform_point');
Cairo-1.109/t/CairoPath.t 000644 001750 000024 00000004503 11747045545 015332 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
#
# Copyright (c) 2004-2012 by the cairo perl team (see the file README)
#
# Licensed under the LGPL, see LICENSE file for more information.
#
# $Id$
#
use strict;
use warnings;
use Cairo;
use Test::More tests => 18;
use constant IMG_WIDTH => 256;
use constant IMG_HEIGHT => 256;
my $surf = Cairo::ImageSurface->create ('rgb24', IMG_WIDTH, IMG_HEIGHT);
my $cr = Cairo::Context->create ($surf);
$cr->new_path;
$cr->move_to (1, 2);
$cr->line_to (3, 4);
$cr->curve_to (5, 6, 7, 8, 9, 10);
$cr->close_path;
my $expected_path = [
{ type => "move-to", points => [[1, 2]] },
{ type => "line-to", points => [[3, 4]] },
{ type => "curve-to", points => [[5, 6], [7, 8], [9, 10]] },
{ type => "close-path", points => [] },
{ type => "move-to", points => [[1, 2]] }
];
my $path = $cr->copy_path;
paths_agree ($path, $expected_path);
# Modifying single point values.
foreach ($path, $expected_path) {
$_->[1]{points}[0][0] = 33;
$_->[1]{points}[0][1] = 44;
$_->[2]{points}[2][0] = 99;
$_->[2]{points}[2][1] = 1010;
}
path_round_trip_ok ($cr, $path, $expected_path);
# Modifying single points.
foreach ($path, $expected_path) {
$_->[1]{points}[0] = [333, 444];
$_->[2]{points}[2] = [77, 88];
}
path_round_trip_ok ($cr, $path, $expected_path);
# Replacing all points.
foreach ($path, $expected_path) {
$_->[1]{points} = [[3333, 4444]];
$_->[2]{points} = [[55, 66], [77, 88], [99, 1010]];
}
path_round_trip_ok ($cr, $path, $expected_path);
# Replacing and adding path segments.
my @cloned_path = @{$path};
foreach (\@cloned_path, $expected_path) {
$_->[1] = {
type => 'curve-to',
points => [[55, 66], [77, 88], [99, 1010]] };
$_->[2] = {
type => 'line-to',
points => [[3333, 4444]] };
splice @{$_}, 3, 0, {
type => 'line-to',
points => [[23, 42]] };
}
path_round_trip_ok ($cr, \@cloned_path, $expected_path);
# Passing bare arrays into Cairo.
$cr->new_path;
$cr->append_path ($expected_path);
paths_agree ($cr->copy_path, $expected_path);
sub path_round_trip_ok {
my ($cr, $path, $expected_path) = @_;
$cr->new_path;
$cr->append_path ($path);
paths_agree ($cr->copy_path, $expected_path);
}
sub paths_agree {
my ($path, $expected_path) = @_;
# Only the first three entries seem to be reliable across cairo versions.
for (0..2) {
is_deeply ($path->[$_], $expected_path->[$_]);
}
}
Cairo-1.109/t/CairoFt.t 000644 001750 000024 00000003007 11664366475 015013 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
#
# Copyright (c) 2007 by the cairo perl team (see the file README)
#
# Licensed under the LGPL, see LICENSE file for more information.
#
# $Id$
#
use strict;
use warnings;
use Test::More;
use Cairo;
unless (Cairo::HAS_FT_FONT && eval 'use Font::FreeType; 1;') {
plan skip_all => 'need Cairo with FreeType support and Font::FreeType';
}
my @files_to_try = qw(
/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf
/usr/share/fonts/truetype/ttf-dejavu/DejaVuSerif.ttf
);
my @files_found = grep { -r $_ } @files_to_try;
my $file = $files_found[0];
unless ($file) {
plan skip_all => 'can\'t find font file';
}
plan tests => 3;
my $ft_face = Font::FreeType->new->face ($file);
my $cr_ft_face = Cairo::FtFontFace->create ($ft_face);
isa_ok ($cr_ft_face, 'Cairo::FtFontFace');
isa_ok ($cr_ft_face, 'Cairo::FontFace');
is ($cr_ft_face->status, 'success');
# make sure freetype font object is correctly referenced
{
sub draw_text {
my $cr = shift;
my $ft_face = Font::FreeType->new->face( $file );
my $face = Cairo::FtFontFace->create($ft_face);
$cr->set_font_face( $face );
$cr->set_font_size( 12 );
$cr->translate( 10 , 10 );
$cr->show_text( "123 123123" );
$cr->stroke;
}
my $surface = Cairo::PdfSurface->create( "test.pdf", 500 , 500 );
my $cr = Cairo::Context->create($surface);
$cr->save;
draw_text( $cr );
$cr->set_font_size( 12 );
$cr->restore;
# must call finish() here so that cairo attemps to use the FtFontFace
$surface->finish;
unlink "test.pdf";
}
Cairo-1.109/t/Cairo.t 000644 001750 000024 00000015022 13544006551 014502 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
#
# Copyright (c) 2004-2012 by the cairo perl team (see the file README)
#
# Licensed under the LGPL, see LICENSE file for more information.
#
# $Id$
#
use strict;
use warnings;
use Test::More tests => 72;
unless (eval 'use Test::Number::Delta; 1;') {
my $reason = 'Test::Number::Delta not available';
*delta_ok = sub { SKIP: { skip $reason, 1 } };
}
use constant IMG_WIDTH => 256;
use constant IMG_HEIGHT => 256;
use Cairo;
my $surf = Cairo::ImageSurface->create ('rgb24', IMG_WIDTH, IMG_HEIGHT);
isa_ok ($surf, 'Cairo::Surface');
my $cr = Cairo::Context->create ($surf);
isa_ok ($cr, 'Cairo::Context');
$cr->save;
$cr->restore;
SKIP: {
skip 'new stuff', 2
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 2, 0);
$cr->push_group();
isa_ok ($cr->get_group_target, 'Cairo::Surface');
isa_ok ($cr->pop_group(), 'Cairo::Pattern');
$cr->push_group_with_content('color');
$cr->pop_group_to_source();
}
$cr->set_operator ('clear');
is ($cr->get_operator, 'clear');
$cr->set_source_rgb (0.5, 0.6, 0.7);
$cr->set_source_rgba (0.5, 0.6, 0.7, 0.8);
my $pat = Cairo::SurfacePattern->create ($surf);
$cr->set_source ($pat);
$cr->set_source_surface ($surf, 23, 42);
$cr->set_tolerance (0.75);
delta_ok ($cr->get_tolerance, 0.75);
$cr->set_antialias ('subpixel');
is ($cr->get_antialias, 'subpixel');
$cr->set_fill_rule ('winding');
is ($cr->get_fill_rule, 'winding');
$cr->set_line_width (3);
is ($cr->get_line_width, 3);
$cr->set_line_cap ('butt');
is ($cr->get_line_cap, 'butt');
$cr->set_line_join ('miter');
is ($cr->get_line_join, 'miter');
$cr->set_dash (0, 2, 4, 6, 4, 2);
$cr->set_dash (0);
SKIP: {
skip 'new stuff', 4
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 4, 0);
$cr->set_dash (0.5, 2.3, 4.5, 6.7, 4.5, 2.3);
my ($offset, @dashes) = $cr->get_dash;
is ($offset, 0.5);
delta_ok (\@dashes, [2.3, 4.5, 6.7, 4.5, 2.3]);
$cr->set_dash (0);
($offset, @dashes) = $cr->get_dash;
is ($offset, 0);
is_deeply (\@dashes, []);
}
$cr->set_miter_limit (2.2);
delta_ok ($cr->get_miter_limit, 2.2);
$cr->translate (2.2, 3.3);
$cr->scale (2.2, 3.3);
$cr->rotate (2.2);
my $mat = Cairo::Matrix->init_identity;
isa_ok ($mat, 'Cairo::Matrix');
$cr->set_matrix ($mat);
isa_ok ($cr->get_matrix, 'Cairo::Matrix');
$cr->transform ($mat);
$cr->identity_matrix;
is_deeply ([$cr->user_to_device (23, 42)], [23, 42]);
is_deeply ([$cr->user_to_device_distance (1, 2)], [1, 2]);
is_deeply ([$cr->device_to_user (23, 42)], [23, 42]);
is_deeply ([$cr->device_to_user_distance (1, 2)], [1, 2]);
$cr->new_path;
SKIP: {
skip 'new stuff', 0
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 2, 0);
$cr->new_sub_path;
}
$cr->move_to (1.1, 2.2);
$cr->line_to (2.2, 3.3);
$cr->curve_to (3.3, 4.4, 5.5, 6.6, 7.7, 8.8);
$cr->arc (4.4, 5.5, 6.6, 7.7, 8.8);
$cr->arc_negative (5.5, 6.6, 7.7, 8.8, 9.9);
$cr->rel_move_to (6.6, 7.7);
$cr->rel_line_to (8.8, 9.9);
$cr->rel_curve_to (9.9, 0.0, 1.1, 2.2, 3.3, 4.4);
$cr->rectangle (0.0, 1.1, 2.2, 3.3);
$cr->close_path;
SKIP: {
skip 'new stuff', 4
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 5, 8);
my ($x1, $y1, $x2, $y2) = $cr->path_extents;
foreach ($x1, $y1, $x2, $y2) {
ok (defined $_);
}
}
$cr->paint;
$cr->paint_with_alpha (0.5);
$cr->mask ($pat);
$cr->mask_surface ($surf, 23, 42);
$cr->stroke;
$cr->stroke_preserve;
$cr->fill;
$cr->fill_preserve;
$cr->copy_page;
$cr->show_page;
ok (!$cr->in_stroke (23, 42));
ok (!$cr->in_fill (23, 42));
my @ext = $cr->stroke_extents;
is (@ext, 4);
@ext = $cr->fill_extents;
is (@ext, 4);
$cr->clip;
$cr->clip_preserve;
$cr->reset_clip;
SKIP: {
skip 'new stuff', 1
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 10, 0);
ok ($cr->in_clip (23, 42));
}
SKIP: {
skip 'new stuff', 7
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 4, 0);
$cr->rectangle (0, 0, 128, 128);
$cr->clip;
my @extents = $cr->clip_extents;
is (@extents, 4);
is ($extents[0], 0);
is ($extents[1], 0);
is ($extents[2], 128);
is ($extents[3], 128);
my @list = $cr->copy_clip_rectangle_list;
is (@list, 1);
is_deeply ($list[0], { x => 0, y => 0, width => 128, height => 128 });
}
$cr->select_font_face ('Sans', 'normal', 'normal');
$cr->set_font_size (12);
$cr->set_font_matrix ($mat);
isa_ok ($cr->get_font_matrix, 'Cairo::Matrix');
my $opt = Cairo::FontOptions->create;
$cr->set_font_options ($opt);
ok ($opt->equal ($cr->get_font_options));
my @glyphs = ({ index => 1, x => 2, y => 3 },
{ index => 2, x => 3, y => 4 },
{ index => 3, x => 4, y => 5 });
$cr->show_text ('Urgs?');
$cr->show_glyphs (@glyphs);
SKIP: {
skip 'new stuff', 1
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 8, 0);
my @clusters = map { {num_bytes => 1, num_glyphs => 1} } (1 .. 3);
my $text = 'abc';
$cr->show_text_glyphs ($text, \@glyphs, \@clusters, ['backward']);
is ($cr->status, 'success');
}
my $face = $cr->get_font_face;
isa_ok ($face, 'Cairo::FontFace');
$cr->set_font_face ($face);
my $ext = $cr->font_extents;
isa_ok ($ext, 'HASH');
ok (exists $ext->{'ascent'});
ok (exists $ext->{'descent'});
ok (exists $ext->{'height'});
ok (exists $ext->{'max_x_advance'});
ok (exists $ext->{'max_y_advance'});
foreach $ext ($cr->text_extents ('Urgs?'),
$cr->glyph_extents (@glyphs)) {
isa_ok ($ext, 'HASH');
ok (exists $ext->{'x_bearing'});
ok (exists $ext->{'y_bearing'});
ok (exists $ext->{'width'});
ok (exists $ext->{'height'});
ok (exists $ext->{'x_advance'});
ok (exists $ext->{'y_advance'});
}
$cr->text_path ('Urgs?');
$cr->glyph_path (@glyphs);
SKIP: {
skip 'new stuff', 0
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 2, 0);
my $options = Cairo::FontOptions->create;
my $matrix = Cairo::Matrix->init_identity;
my $ctm = Cairo::Matrix->init_identity;
my $font = Cairo::ScaledFont->create ($face, $matrix, $ctm, $options);
$cr->set_scaled_font ($font);
}
SKIP: {
skip 'new stuff', 1
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 4, 0);
isa_ok ($cr->get_scaled_font, 'Cairo::ScaledFont');
}
isa_ok ($cr->get_source, 'Cairo::Pattern');
SKIP: {
skip 'new stuff', 1
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 6, 0);
ok ($cr->has_current_point);
}
my @pnt = $cr->get_current_point;
is (@pnt, 2);
isa_ok ($cr->get_target, 'Cairo::Surface');
my $path = $cr->copy_path;
isa_ok ($path, 'ARRAY');
$path = $cr->copy_path_flat;
isa_ok ($path, 'ARRAY');
$cr->append_path ($path);
is ($cr->status, 'success');
SKIP: {
skip 'new stuff', 2
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 16, 0);
$cr->tag_begin("Link","https://www.perl.org");
is ($cr->status, 'success');
$cr->tag_end("Link");
is ($cr->status, 'success');
}
Cairo-1.109/t/CairoRegion.t 000644 001750 000024 00000002533 11664366475 015670 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
#
# Copyright (c) 2011 by the cairo perl team (see the file README)
#
# Licensed under the LGPL, see LICENSE file for more information.
#
use strict;
use warnings;
use Test::More;
use Cairo;
unless (Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 10, 0)) {
plan skip_all => 'need cairo 1.10';
}
plan tests => 19;
my $region = Cairo::Region->create;
isa_ok ($region, 'Cairo::Region');
$region = Cairo::Region->create ({x=>10, y=>10, width=>5, height=>5});
isa_ok ($region, 'Cairo::Region');
$region = Cairo::Region->create ({x=>10, y=>10, width=>5, height=>5},
{x=>0, y=>0, width=>5, height=>5});
isa_ok ($region, 'Cairo::Region');
is ($region->status, 'success');
is_deeply ($region->get_extents, {x=>0, y=>0, width=>15, height=>15});
is ($region->num_rectangles, 2);
is_deeply ($region->get_rectangle (1), {x=>10, y=>10, width=>5, height=>5});
ok (!$region->is_empty);
ok ($region->contains_point (12, 13));
is ($region->contains_rectangle ({x=>7, y=>7, width=>5, height=>5}), 'part');
ok ($region->equal ($region));
$region->translate (0, 0);
my $other = {x=>0, y=>0, width=>15, height=>15};
foreach my $method (qw/intersect subtract union xor/) {
is ($region->$method ($region), 'success', $method);
my $rect_method = $method . '_rectangle';
is ($region->$rect_method ($other), 'success', $rect_method);
}
Cairo-1.109/t/CairoFont.t 000644 001750 000024 00000005555 13110362063 015333 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
#
# Copyright (c) 2004-2005 by the cairo perl team (see the file README)
#
# Licensed under the LGPL, see LICENSE file for more information.
#
# $Id$
#
use strict;
use warnings;
use utf8;
use Test::More tests => 29;
use constant IMG_WIDTH => 256;
use constant IMG_HEIGHT => 256;
use Cairo;
my $options = Cairo::FontOptions->create;
isa_ok ($options, 'Cairo::FontOptions');
is ($options->status, 'success');
$options->merge (Cairo::FontOptions->create);
ok ($options->equal ($options));
is ($options->hash, 0);
$options->set_antialias ('subpixel');
is ($options->get_antialias, 'subpixel');
$options->set_subpixel_order ('rgb');
is ($options->get_subpixel_order, 'rgb');
$options->set_hint_style ('full');
is ($options->get_hint_style, 'full');
$options->set_hint_metrics ('on');
is ($options->get_hint_metrics, 'on');
# --------------------------------------------------------------------------- #
my $surf = Cairo::ImageSurface->create ('rgb24', IMG_WIDTH, IMG_HEIGHT);
my $cr = Cairo::Context->create ($surf);
my $face = $cr->get_font_face;
is ($face->status, 'success');
SKIP: {
skip 'new stuff', 1
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 2, 0);
ok (defined $face->get_type);
}
my $matrix = Cairo::Matrix->init_identity;
my $ctm = Cairo::Matrix->init_identity;
my $font = Cairo::ScaledFont->create ($face, $matrix, $ctm, $options);
isa_ok ($font, 'Cairo::ScaledFont');
SKIP: {
skip 'scaled font tests', 10
unless $font->status eq 'success';
isa_ok ($font->extents, 'HASH');
isa_ok ($font->glyph_extents ({ index => 1, x => 2, y => 3 }), 'HASH');
skip 'new stuff', 8
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 2, 0);
$cr->set_scaled_font ($font);
is ($font->status, 'success');
is ($cr->status, 'success');
ok (defined $font->get_type);
isa_ok ($font->text_extents('Bla'), 'HASH');
isa_ok ($font->get_font_face, 'Cairo::FontFace');
isa_ok ($font->get_font_matrix, 'Cairo::Matrix');
isa_ok ($font->get_ctm, 'Cairo::Matrix');
isa_ok ($font->get_font_options, 'Cairo::FontOptions');
}
SKIP: {
skip 'new stuff', 2
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 8, 0);
isa_ok ($font->get_scale_matrix, 'Cairo::Matrix');
my $text = 'æſðđŋ';
my ($status, $glyphs, $clusters, $flags) =
$font->text_to_glyphs (5, 10, $text);
skip 'show_text_glyphs', 1
unless $status eq 'success';
$cr->show_text_glyphs ($text, $glyphs, $clusters, $flags);
is ($cr->status, 'success');
}
# --------------------------------------------------------------------------- #
SKIP: {
skip 'toy font face', 6
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 8, 0);
my $face = Cairo::ToyFontFace->create ('Sans', 'italic', 'bold');
isa_ok ($face, 'Cairo::ToyFontFace');
isa_ok ($face, 'Cairo::FontFace');
is ($face->status, 'success');
is ($face->get_family, 'Sans');
is ($face->get_slant, 'italic');
is ($face->get_weight, 'bold');
}
Cairo-1.109/t/CairoSurface.t 000644 001750 000024 00000030236 13757124331 016022 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
#
# Copyright (c) 2004-2005 by the cairo perl team (see the file README)
#
# Licensed under the LGPL, see LICENSE file for more information.
#
# $Id$
#
use strict;
use warnings;
use Config; # for byteorder
use Test::More tests => 100;
use constant IMG_WIDTH => 256;
use constant IMG_HEIGHT => 256;
use Cairo;
unless (eval 'use Test::Number::Delta; 1;') {
my $reason = 'Test::Number::Delta not available';
*delta_ok = sub { SKIP: { skip $reason, 1 } };
}
my $surf = Cairo::ImageSurface->create ('rgb24', IMG_WIDTH, IMG_HEIGHT);
isa_ok ($surf, 'Cairo::ImageSurface');
isa_ok ($surf, 'Cairo::Surface');
SKIP: {
skip 'new stuff', 2
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 2, 0);
is ($surf->get_content, 'color');
is ($surf->get_format, 'rgb24');
}
is ($surf->get_width, IMG_WIDTH);
is ($surf->get_height, IMG_HEIGHT);
{
my $data = pack ('CCCC', 0, 0, 0, 0);
my $surf = Cairo::ImageSurface->create_for_data (
$data, 'argb32', 1, 1, 4);
isa_ok ($surf, 'Cairo::ImageSurface');
isa_ok ($surf, 'Cairo::Surface');
SKIP: {
skip 'new stuff', 4
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 2, 0);
is ($surf->get_data, $data);
is ($surf->get_stride, 4);
# Change the image data and make sure $data gets updated accordingly.
my $cr = Cairo::Context->create ($surf);
$cr->set_source_rgba (1.0, 0, 0, 1.0);
$cr->rectangle (0, 0, 1, 1);
$cr->fill;
is ($surf->get_data, $data);
my $bo = $Config{byteorder}+1;
if ($bo == 1234) {
is ($surf->get_data, pack ('CCCC', 0, 0, 255, 255));
} elsif ($bo == 4321) {
is ($surf->get_data, pack ('CCCC', 255, 255, 0, 0));
} else {
ok (1, 'Skipping get_data test; unknown endianness');
}
}
}
my $similar = Cairo::Surface->create_similar ($surf, 'color', IMG_WIDTH, IMG_HEIGHT);
isa_ok ($similar, 'Cairo::ImageSurface');
isa_ok ($similar, 'Cairo::Surface');
# Test that create_similar can be called with both conventions.
{
my $similar = $surf->create_similar ('color', IMG_WIDTH, IMG_HEIGHT);
isa_ok ($similar, 'Cairo::ImageSurface');
isa_ok ($similar, 'Cairo::Surface');
eval { Cairo::Surface->create_similar (1, 2) };
like ($@, qr/Usage/);
eval { Cairo::Surface->create_similar (1, 2, 3, 4, 5) };
like ($@, qr/Usage/);
}
# Test that the enum wrappers differentiate between color and color-alpha.
SKIP: {
skip 'content tests', 2
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 2, 0);
my $tmp = Cairo::Surface->create_similar ($surf, 'color-alpha', IMG_WIDTH, IMG_HEIGHT);
is ($tmp->get_content, 'color-alpha');
$tmp = Cairo::Surface->create_similar ($surf, 'color', IMG_WIDTH, IMG_HEIGHT);
is ($tmp->get_content, 'color');
}
$surf->set_device_offset (23, 42);
SKIP: {
skip 'new stuff', 2
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 2, 0);
is_deeply ([$surf->get_device_offset], [23, 42]);
$surf->set_fallback_resolution (72, 72);
is ($surf->get_type, 'image');
}
is ($surf->status, 'success');
isa_ok ($surf->get_font_options, 'Cairo::FontOptions');
$surf->mark_dirty;
$surf->mark_dirty_rectangle (10, 10, 10, 10);
$surf->flush;
SKIP: {
skip 'new stuff', 1
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 6, 0);
$surf->copy_page;
$surf->show_page;
like (Cairo::Format::stride_for_width ('argb32', 23), qr/\A\d+\z/);
}
SKIP: {
skip 'new stuff', 2
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 8, 0);
$surf->set_fallback_resolution (72, 72);
delta_ok ([$surf->get_fallback_resolution], [72, 72]);
ok (defined $surf->has_show_text_glyphs);
}
SKIP: {
skip 'new stuff', 1
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 10, 0);
my $rect_surf = Cairo::Surface->create_for_rectangle ($surf, 0, 0, 10, 10);
isa_ok ($rect_surf, 'Cairo::Surface');
}
$surf->finish;
# --------------------------------------------------------------------------- #
sub clear {
if (Cairo::VERSION() < Cairo::VERSION_ENCODE (1, 2, 0)) {
my $cr = Cairo::Context->create ($surf);
$cr->set_operator ('clear');
$cr->paint;
}
}
SKIP: {
skip 'png surface', 16
unless Cairo::HAS_PNG_FUNCTIONS;
my $surf = Cairo::ImageSurface->create ('rgb24', IMG_WIDTH, IMG_HEIGHT);
clear ($surf);
is ($surf->write_to_png ('tmp.png'), 'success');
is ($surf->write_to_png_stream (sub {
my ($closure, $data) = @_;
is ($closure, 'blub');
like ($data, qr/PNG/);
die 'no-memory';
}, 'blub'), 'no-memory');
is ($surf->write_to_png_stream (sub {
my ($closure, $data) = @_;
is ($closure, undef);
like ($data, qr/PNG/);
die 'no-memory';
}), 'no-memory');
$surf = Cairo::ImageSurface->create_from_png ('tmp.png');
isa_ok ($surf, 'Cairo::ImageSurface');
isa_ok ($surf, 'Cairo::Surface');
open my $fh, 'tmp.png';
$surf = Cairo::ImageSurface->create_from_png_stream (sub {
my ($closure, $length) = @_;
my $buffer;
if ($length != sysread ($fh, $buffer, $length)) {
die 'no-memory';
}
return $buffer;
});
isa_ok ($surf, 'Cairo::ImageSurface');
isa_ok ($surf, 'Cairo::Surface');
is ($surf->status, 'success');
close $fh;
$surf = Cairo::ImageSurface->create_from_png_stream (sub {
my ($closure, $length) = @_;
is ($closure, 'blub');
die 'read-error';
}, 'blub');
isa_ok ($surf, 'Cairo::ImageSurface');
isa_ok ($surf, 'Cairo::Surface');
is ($surf->status, 'read-error');
unlink 'tmp.png';
}
SKIP: {
skip 'pdf surface', 18
unless Cairo::HAS_PDF_SURFACE;
my $surf = Cairo::PdfSurface->create ('tmp.pdf', IMG_WIDTH, IMG_HEIGHT);
isa_ok ($surf, 'Cairo::PdfSurface');
isa_ok ($surf, 'Cairo::Surface');
SKIP: {
skip 'new stuff', 0
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 2, 0);
$surf->set_size (23, 42);
}
# create_similar might return any kind of surface
$surf = Cairo::Surface->create_similar ($surf, 'alpha', IMG_WIDTH, IMG_HEIGHT);
isa_ok ($surf, 'Cairo::Surface');
SKIP: {
skip 'create_for_stream on pdf surfaces', 4
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 2, 0);
$surf = Cairo::PdfSurface->create_for_stream (sub {
my ($closure, $data) = @_;
is ($closure, 'blub');
like ($data, qr/PDF/);
die 'write-error';
}, 'blub', IMG_WIDTH, IMG_HEIGHT);
isa_ok ($surf, 'Cairo::PdfSurface');
isa_ok ($surf, 'Cairo::Surface');
}
SKIP: {
skip 'new stuff', 6
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 10, 0);
my $surf = Cairo::PdfSurface->create ('tmp.pdf', IMG_WIDTH, IMG_HEIGHT);
$surf->restrict_to_version ('1-4');
$surf->restrict_to_version ('1-5');
my @versions = Cairo::PdfSurface::get_versions();
ok (scalar @versions > 0);
is ($versions[0], '1-4');
@versions = Cairo::PdfSurface->get_versions();
ok (scalar @versions > 0);
is ($versions[0], '1-4');
like (Cairo::PdfSurface::version_to_string('1-4'), qr/1\.4/);
like (Cairo::PdfSurface->version_to_string('1-4'), qr/1\.4/);
}
SKIP: {
skip 'new stuff', 4
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 10, 0);
my $mime_data = 'mime data for {set,get}_mime_data';
is ($surf->MIME_TYPE_JPEG, 'image/jpeg');
is ($surf->set_mime_data($surf->MIME_TYPE_JPEG, $mime_data), 'success');
my $recovered_mime_data = $surf->get_mime_data('unset mime type');
is ($recovered_mime_data, undef);
$recovered_mime_data = $surf->get_mime_data($surf->MIME_TYPE_JPEG);
is ($recovered_mime_data, $mime_data);
}
SKIP: {
skip 'new stuff', 2
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 12, 0);
is ($surf->supports_mime_type(Cairo::Surface::MIME_TYPE_JPEG), 1);
is ($surf->supports_mime_type('unsupported mime type'), 0);
}
SKIP: {
skip 'new stuff', 1
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 16, 0);
$surf->set_metadata("title","Testing metadata");
$surf->set_metadata("author","Johan Vromans");
$surf->set_metadata("subject","cairo_pdf_set_metadata");
ok(1); # No get_metadata, so assume OK if we're still alive
}
SKIP: {
skip 'new stuff', 3
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 16, 0);
$surf->set_page_label('Page label');
is ($surf->status(), 'success');
$surf->set_thumbnail_size(20, 20);
is ($surf->status(), 'success');
my $parent = $surf->add_outline($surf->OUTLINE_ROOT(), 'Cover', "dest='page=1'", ['bold']);
$parent = $surf->add_outline($parent, 'Chapter 1', 'page=2', ['bold', 'open']);
$parent = $surf->add_outline($parent, 'Section 1', 'page=2', ['open']);
$parent = $surf->add_outline($parent, 'Section 1.1', 'page=2', ['italic']);
$parent = $surf->add_outline($parent, 'Review', 'page=2', []);
is ($surf->status(), 'success');
}
unlink 'tmp.pdf';
}
SKIP: {
skip 'ps surface', 14
unless Cairo::HAS_PS_SURFACE;
my $surf = Cairo::PsSurface->create ('tmp.ps', IMG_WIDTH, IMG_HEIGHT);
skip 'create returned no ps surface', 15
unless defined $surf && $surf->isa ('Cairo::PsSurface');
isa_ok ($surf, 'Cairo::PsSurface');
isa_ok ($surf, 'Cairo::Surface');
SKIP: {
skip 'new stuff', 0
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 2, 0);
$surf->set_size (23, 42);
$surf->dsc_comment("Bla?");
$surf->dsc_begin_setup;
$surf->dsc_begin_page_setup;
}
# create_similar might return any kind of surface
$surf = Cairo::Surface->create_similar ($surf, 'alpha', IMG_WIDTH, IMG_HEIGHT);
isa_ok ($surf, 'Cairo::Surface');
unlink 'tmp.ps';
SKIP: {
skip 'create_for_stream on ps surfaces', 4
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 2, 0);
skip 'create_for_stream on ps surfaces', 4
if (Cairo::VERSION() >= Cairo::VERSION_ENCODE (1, 4, 0) &&
Cairo::VERSION() < Cairo::VERSION_ENCODE (1, 4, 8));
$surf = Cairo::PsSurface->create_for_stream (sub {
my ($closure, $data) = @_;
is ($closure, 'blub');
like ($data, qr/PS/);
die 'write-error';
}, 'blub', IMG_WIDTH, IMG_HEIGHT);
isa_ok ($surf, 'Cairo::PsSurface');
isa_ok ($surf, 'Cairo::Surface');
}
SKIP: {
skip 'new stuff', 7
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 6, 0);
$surf->restrict_to_level ('2');
$surf->restrict_to_level ('3');
my @levels = Cairo::PsSurface::get_levels();
ok (scalar @levels > 0);
is ($levels[0], '2');
@levels = Cairo::PsSurface->get_levels();
ok (scalar @levels > 0);
is ($levels[0], '2');
like (Cairo::PsSurface::level_to_string('2'), qr/2/);
like (Cairo::PsSurface->level_to_string('3'), qr/3/);
$surf->set_eps (1);
is ($surf->get_eps, 1);
}
}
SKIP: {
skip 'svg surface', 12
unless Cairo::HAS_SVG_SURFACE;
my $surf = Cairo::SvgSurface->create ('tmp.svg', IMG_WIDTH, IMG_HEIGHT);
isa_ok ($surf, 'Cairo::SvgSurface');
isa_ok ($surf, 'Cairo::Surface');
$surf->restrict_to_version ('1-1');
$surf->restrict_to_version ('1-2');
unlink 'tmp.svg';
SKIP: {
skip 'create_for_stream on svg surfaces', 4
if (Cairo::VERSION() >= Cairo::VERSION_ENCODE (1, 4, 0) &&
Cairo::VERSION() < Cairo::VERSION_ENCODE (1, 4, 8));
$surf = Cairo::SvgSurface->create_for_stream (sub {
my ($closure, $data) = @_;
is ($closure, 'blub');
like ($data, qr/xml/);
die 'write-error';
}, 'blub', IMG_WIDTH, IMG_HEIGHT);
isa_ok ($surf, 'Cairo::SvgSurface');
isa_ok ($surf, 'Cairo::Surface');
}
my @versions = Cairo::SvgSurface::get_versions();
ok (scalar @versions > 0);
is ($versions[0], '1-1');
@versions = Cairo::SvgSurface->get_versions();
ok (scalar @versions > 0);
is ($versions[0], '1-1');
like (Cairo::SvgSurface::version_to_string('1-1'), qr/1\.1/);
like (Cairo::SvgSurface->version_to_string('1-1'), qr/1\.1/);
}
SKIP: {
skip 'recording surface', 7
unless Cairo::HAS_RECORDING_SURFACE;
my $surf = Cairo::RecordingSurface->create (
'color',
{x=>10, y=>10, width=>5, height=>5});
isa_ok ($surf, 'Cairo::RecordingSurface');
isa_ok ($surf, 'Cairo::Surface');
# Test that the extents rectangle was marshalled correctly.
my $cr = Cairo::Context->create ($surf);
$cr->move_to (0, 0);
$cr->line_to (30, 30);
$cr->paint;
is_deeply ([$surf->ink_extents], [10, 10, 5, 5]);
$surf = Cairo::RecordingSurface->create ('color', undef);
isa_ok ($surf, 'Cairo::RecordingSurface');
isa_ok ($surf, 'Cairo::Surface');
SKIP: {
skip 'get_extents', 2
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 12, 0);
$surf = Cairo::RecordingSurface->create ('color', undef);
is ($surf->get_extents(), undef);
$surf = Cairo::RecordingSurface->create ('color', {x => 5, y => 10, width => 15, height => 20});
is_deeply ($surf->get_extents(), {x => 5, y => 10, width => 15, height => 20});
}
}
Cairo-1.109/t/00-loading.t 000644 001750 000024 00000001576 11706207064 015310 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
#
# Copyright (c) 2004-2012 by the cairo perl team (see the file README)
#
# Licensed under the LGPL, see LICENSE file for more information.
#
use strict;
use warnings;
use Test::More tests => 18;
BEGIN {
ok (! eval "use Cairo 2.000; 1");
ok (eval "use Cairo 1.000; 1");
}
ok(defined Cairo::LIB_VERSION);
ok(defined Cairo::LIB_VERSION_ENCODE (1, 0, 0));
ok(defined Cairo->LIB_VERSION);
ok(defined Cairo->LIB_VERSION_ENCODE (1, 0, 0));
ok(defined Cairo::lib_version);
ok(defined Cairo::lib_version_string);
ok(defined Cairo->lib_version);
ok(defined Cairo->lib_version_string);
# Deprecated names:
ok(defined Cairo::VERSION);
ok(defined Cairo::VERSION_ENCODE (1, 0, 0));
ok(defined Cairo->VERSION);
ok(defined Cairo->VERSION_ENCODE (1, 0, 0));
ok(defined Cairo::version);
ok(defined Cairo::version_string);
ok(defined Cairo->version);
ok(defined Cairo->version_string);
Cairo-1.109/t/CairoPattern.t 000644 001750 000024 00000006240 11664366475 016061 0 ustar 00brian staff 000000 000000 #!/usr/bin/perl
#
# Copyright (c) 2004-2005 by the cairo perl team (see the file README)
#
# Licensed under the LGPL, see LICENSE file for more information.
#
# $Id$
#
use strict;
use warnings;
use Test::More tests => 48;
unless (eval 'use Test::Number::Delta; 1;') {
my $reason = 'Test::Number::Delta not available';
*delta_ok = sub { SKIP: { skip $reason, 1 } };
}
use constant IMG_WIDTH => 256;
use constant IMG_HEIGHT => 256;
use Cairo;
sub common_pattern_ok {
my ($pat, $type) = @_;
isa_ok ($pat, $type);
isa_ok ($pat, 'Cairo::Pattern');
$pat->set_extend ('repeat');
is ($pat->get_extend, 'repeat', "$type set|get_extend");
$pat->set_filter ('good');
is ($pat->get_filter, 'good', "$type set|get_filter");
my $matrix = Cairo::Matrix->init_identity;
$pat->set_matrix ($matrix);
isa_ok ($pat->get_matrix, 'Cairo::Matrix', "$type set|get_matrix");
is ($pat->status, 'success', "$type status");
}
{
my $pat = Cairo::SolidPattern->create_rgb(1.0, 0.0, 0.0);
common_pattern_ok ($pat, 'Cairo::SolidPattern');
}
{
my $pat = Cairo::SolidPattern->create_rgba(1.0, 0.0, 0.0, 1.0);
common_pattern_ok ($pat, 'Cairo::SolidPattern');
}
{
my $surf = Cairo::ImageSurface->create ('rgb24', IMG_WIDTH, IMG_HEIGHT);
my $pat = Cairo::SurfacePattern->create ($surf);
common_pattern_ok ($pat, 'Cairo::SurfacePattern');
}
{
my $pat = Cairo::LinearGradient->create (1, 2, 3, 4);
common_pattern_ok ($pat, 'Cairo::LinearGradient');
isa_ok ($pat, 'Cairo::Gradient');
$pat->add_color_stop_rgb (1, 0.5, 0.6, 0.7);
$pat->add_color_stop_rgba (1, 0.5, 0.6, 0.7, 0.8);
is ($pat->status, 'success');
}
{
my $pat = Cairo::RadialGradient->create (1, 2, 3, 4, 5, 6);
common_pattern_ok ($pat, 'Cairo::RadialGradient');
isa_ok ($pat, 'Cairo::Gradient');
$pat->add_color_stop_rgb (1, 0.5, 0.6, 0.7);
$pat->add_color_stop_rgba (1, 0.5, 0.6, 0.7, 0.8);
is ($pat->status, 'success');
}
SKIP: {
skip 'new stuff', 1
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 2, 0);
my $pat = Cairo::RadialGradient->create (1, 2, 3, 4, 5, 6);
is ($pat->get_type, 'radial');
}
SKIP: {
skip 'new stuff', 13,
unless Cairo::VERSION >= Cairo::VERSION_ENCODE (1, 4, 0);
{
my $pat = Cairo::SolidPattern->create_rgb(1.0, 0.0, 0.0);
my ($r, $g, $b, $a) = $pat->get_rgba;
delta_ok ($r, 1.0);
delta_ok ($g, 0.0);
delta_ok ($b, 0.0);
delta_ok ($a, 1.0);
is ($pat->status, 'success');
}
{
my $surf = Cairo::ImageSurface->create ('rgb24', IMG_WIDTH, IMG_HEIGHT);
my $pat = Cairo::SurfacePattern->create ($surf);
isa_ok ($pat->get_surface, 'Cairo::ImageSurface');
is ($pat->status, 'success');
}
{
my $pat = Cairo::LinearGradient->create (1, 2, 3, 4);
$pat->add_color_stop_rgba (0.25, 1, 0, 1, 0);
$pat->add_color_stop_rgba (0.75, 0, 1, 0, 1);
delta_ok ([$pat->get_color_stops], [[0.25, 1, 0, 1, 0], [0.75, 0, 1, 0, 1]]);
is ($pat->status, 'success');
}
{
my $pat = Cairo::LinearGradient->create (1.5, 2.5, 3.5, 4.5);
delta_ok ([$pat->get_points], [1.5, 2.5, 3.5, 4.5]);
is ($pat->status, 'success');
}
{
my $pat = Cairo::RadialGradient->create (1.5, 2.5, 3.5, 4.5, 5.5, 6.5);
delta_ok ([$pat->get_circles], [1.5, 2.5, 3.5, 4.5, 5.5, 6.5]);
is ($pat->status, 'success');
}
}
Cairo-1.109/inc/MakeHelper.pm 000644 001750 000024 00000026767 12567227240 016167 0 ustar 00brian staff 000000 000000 #
# this is all hacky etc. it works so it's gonna stay for now. it is not and
# should not be installed.
#
# $Id$
#
package MakeHelper;
use strict;
use warnings;
use IO::File;
use File::Spec;
our $autogen_dir = '.';
# --------------------------------------------------------------------------- #
# copied/borrowed from Gtk2-Perl's CodeGen
sub write_boot
{
my %opts = (
ignore => '^[^:]+$', # ignore package with no colons in it
filename => File::Spec->catdir ($autogen_dir,
'cairo-perl-boot.xsh'),
'glob' => File::Spec->catfile ('xs', '*.xs'),
@_,
);
my $ignore = $opts{ignore};
my $file = IO::File->new (">$opts{filename}")
or die "Cannot write $opts{filename}: $!";
print $file "\n\n/* This file is automatically generated, any changes made here will be lost! */\n\n";
my %boot=();
my @xs_files = 'ARRAY' eq ref $opts{xs_files}
? @{ $opts{xs_files} }
: glob $opts{'glob'};
foreach my $xsfile (@xs_files) {
my $in = IO::File->new ($xsfile)
or die "can't open $xsfile: $!\n";
while (<$in>) {
next unless m/^MODULE\s*=\s*(\S+)/;
#warn "found $1 in $&\n";
my $package = $1;
next if $package =~ m/$ignore/;
$package =~ s/:/_/g;
my $sym = "boot_$package";
print $file "CAIRO_PERL_CALL_BOOT ($sym);\n"
unless $boot{$sym};
$boot{$sym}++;
}
close $in;
}
close $file;
}
# --------------------------------------------------------------------------- #
sub name
{
$_[0] =~ /cairo_(\w+)_t/;
return $1;
}
sub do_typemaps
{
my %objects = %{shift ()};
my %structs = %{shift ()};
my %enums = %{shift ()};
my %flags = %{shift ()};
my %object_guards = %{shift ()};
my %struct_guards = %{shift ()};
my %enum_guards = %{shift ()};
my %flag_guards = %{shift ()};
my $cairo_perl = File::Spec->catfile ($autogen_dir,
'cairo-perl-auto.typemap');
open TYPEMAP, '>', $cairo_perl
or die "unable to open ($cairo_perl) for output";
print TYPEMAP <catfile ($autogen_dir,
'cairo-perl-auto.h');
open HEADER, '>', $header
or die "unable to open ($header) for output";
print HEADER <
EOS
sub mangle
{
my $mangled = shift;
$mangled =~ s/_t$//;
$mangled =~ s/([^_]+)/ucfirst $1/ge;
$mangled =~ s/_//g;
return $mangled;
}
sub reference
{
my $ref = shift;
$ref =~ s/_t$//;
$ref .= '_reference';
return $ref;
}
# ------------------------------------------------------------------- #
print HEADER "\n/* objects */\n\n";
foreach (sort(keys %objects))
{
/^(.+) \*/;
my $type = $1;
my $mangled = mangle ($type);
my $ref = reference ($type);
if (exists $object_guards{$type}) {
print HEADER "$object_guards{$type}\n";
}
print HEADER <<"EOS";
typedef $type ${type}_noinc;
typedef $type ${type}_ornull;
#define Sv$mangled(sv) (($type *) cairo_object_from_sv (sv, "$objects{$_}"))
#define Sv${mangled}_ornull(sv) (((sv) && SvOK (sv)) ? Sv$mangled(sv) : NULL)
#define newSV$mangled(object) (cairo_object_to_sv (($type *) $ref (object), "$objects{$_}"))
#define newSV${mangled}_noinc(object) (cairo_object_to_sv (($type *) object, "$objects{$_}"))
#define newSV${mangled}_ornull(object) (((object) == NULL) ? &PL_sv_undef : newSV$mangled(object))
EOS
if (exists $object_guards{$type}) {
print HEADER "#endif /* $object_guards{$type} */\n";
}
}
# ------------------------------------------------------------------- #
print HEADER "\n/* structs */\n\n";
foreach (sort(keys %structs))
{
/^(.+) \*/;
my $type = $1;
my $mangled = mangle ($type);
if (exists $struct_guards{$type}) {
print HEADER "$struct_guards{$type}\n";
}
print HEADER <<"EOS";
typedef $type ${type}_ornull;
#define Sv$mangled(sv) (($type *) cairo_struct_from_sv (sv, "$structs{$_}"))
#define Sv${mangled}_ornull(sv) (((sv) && SvOK (sv)) ? Sv$mangled(sv) : NULL)
#define newSV$mangled(struct_) (cairo_struct_to_sv (($type *) struct_, "$structs{$_}"))
#define newSV${mangled}_ornull(struct_) (((struct_) == NULL) ? &PL_sv_undef : newSV$mangled(struct_))
EOS
if (exists $struct_guards{$type}) {
print HEADER "#endif /* $struct_guards{$type} */\n";
}
}
# ------------------------------------------------------------------- #
print HEADER "\n/* enums */\n\n";
foreach my $type (sort(keys %enums))
{
my $mangled = mangle ($type);
my $name = name ($type);
next unless @{$enums{$type}};
if (exists $enum_guards{$type}) {
print HEADER "$enum_guards{$type}\n";
}
print HEADER <<"EOS";
$type cairo_${name}_from_sv (SV * $name);
SV * cairo_${name}_to_sv ($type val);
#define Sv$mangled(sv) (cairo_${name}_from_sv (sv))
#define newSV$mangled(val) (cairo_${name}_to_sv (val))
EOS
if (exists $enum_guards{$type}) {
print HEADER "#endif /* $enum_guards{$type} */\n";
}
}
# ------------------------------------------------------------------- #
print HEADER "\n/* flags */\n\n";
foreach my $type (sort(keys %flags))
{
my $mangled = mangle ($type);
my $name = name ($type);
next unless @{$flags{$type}};
if (exists $flag_guards{$type}) {
print HEADER "$flag_guards{$type}\n";
}
print HEADER <<"EOS";
$type cairo_${name}_from_sv (SV * $name);
SV * cairo_${name}_to_sv ($type val);
#define Sv$mangled(sv) (cairo_${name}_from_sv (sv))
#define newSV$mangled(val) (cairo_${name}_to_sv (val))
EOS
if (exists $flag_guards{$type}) {
print HEADER "#endif /* $flag_guards{$type} */\n";
}
}
close HEADER;
return ($cairo_perl);
}
# --------------------------------------------------------------------------- #
sub canonicalize_enum_name
{
my ($name, $prefix) = @_;
$name =~ s/$prefix//;
$name =~ tr/_/-/;
$name = lc ($name);
return $name;
}
sub enum_if_tree_from
{
my ($prefix, @enums) = @_;
my $str = '';
my $is_first = 1;
foreach my $full (@enums)
{
my $name = canonicalize_enum_name($full, $prefix);
# +1 so that strncmp also looks at the trailing \0, and
# discerns 'color' and 'color-alpha', for example.
my $len = length ($name) + 1;
my $conditional = $is_first ? 'if' : 'else if';
$str .= <<"EOS";
$conditional (strncmp (str, "$name", $len) == 0)
return $full;
EOS
$is_first = 0;
}
return $str;
}
sub enum_if_tree_to
{
my ($prefix, @enums) = @_;
my $str = '';
my $is_first = 1;
foreach my $full (@enums)
{
my $name = canonicalize_enum_name($full, $prefix);
my $conditional = $is_first ? 'if' : 'else if';
$str .= <<"EOS";
$conditional (val == $full)
return newSVpv ("$name", 0);
EOS
$is_first = 0;
}
return $str;
}
sub do_enums
{
my %enums = %{shift ()};
my %guards = %{shift ()};
my $cairo_enums = 'cairo-perl-enums.c';
open ENUMS, '>', $cairo_enums
or die "unable to open ($cairo_enums) for output";
print ENUMS <<'EOS';
/*
* This file was automatically generated. Do not edit.
*/
#include
EOS
foreach my $type (sort(keys %enums))
{
my $name = name($type);
my @enum_values = @{$enums{$type}};
next unless @enum_values;
my $value_list =
join ", ", map {
canonicalize_enum_name($_, $enum_values[0])
} @enum_values[1..$#enum_values];
my $tree_from = enum_if_tree_from (@enum_values);
my $tree_to = enum_if_tree_to (@enum_values);
if (exists $guards{$type}) {
print ENUMS "$guards{$type}\n\n";
}
print ENUMS <<"EOS";
$type
cairo_${name}_from_sv (SV * $name)
{
char * str = SvPV_nolen ($name);
$tree_from
croak ("`%s' is not a valid $type value; valid values are: $value_list", str);
return 0;
}
SV *
cairo_${name}_to_sv ($type val)
{
$tree_to
warn ("unknown $type value %d encountered", val);
return &PL_sv_undef;
}
EOS
if (exists $guards{$type}) {
print ENUMS "#endif /* $guards{$type} */\n";
}
}
close ENUMS;
}
# --------------------------------------------------------------------------- #
sub flag_if_tree_from
{
my ($prefix, @flags) = @_;
my $str = '';
my $is_first = 1;
foreach my $full (@flags)
{
my $name = canonicalize_enum_name($full, $prefix);
# +1 so that strncmp also looks at the trailing \0, and
# discerns 'color' and 'color-alpha', for example.
my $len = length ($name) + 1;
my $conditional = $is_first ? 'if' : 'else if';
$str .= <<"EOS";
$conditional (strncmp (str, "$name", $len) == 0) {
return $full;
}
EOS
$is_first = 0;
}
return $str;
}
sub flag_if_tree_to
{
my ($prefix, @flags) = @_;
my $str = '';
foreach my $full (@flags)
{
my $name = canonicalize_enum_name($full, $prefix);
$str .= <<"EOS";
if ((val & $full) == $full) {
val -= $full;
av_push (flags, newSVpv ("$name", 0));
}
EOS
}
return $str;
}
sub do_flags
{
my %flags = %{shift ()};
my %guards = %{shift ()};
my $cairo_flags = 'cairo-perl-flags.c';
open FLAGS, '>', $cairo_flags
or die "unable to open ($cairo_flags) for output";
print FLAGS <<'EOS';
/*
* This file was automatically generated. Do not edit.
*/
#include
#include
EOS
foreach my $type (sort(keys %flags))
{
my $name = name($type);
my @flag_values = @{$flags{$type}};
next unless @flag_values;
my $value_list =
join ", ", map {
canonicalize_enum_name($_, $flag_values[0])
} @flag_values[1..$#flag_values];
my $tree_from = flag_if_tree_from (@flag_values);
my $tree_to = flag_if_tree_to (@flag_values);
if (exists $guards{$type}) {
print FLAGS "$guards{$type}\n\n";
}
print FLAGS <<"EOS";
static $type
cairo_${name}_from_sv_part (const char *str)
{
$tree_from
croak ("`%s' is not a valid $type value; valid values are: $value_list", str);
return 0;
}
$type
cairo_${name}_from_sv (SV * $name)
{
if (cairo_perl_sv_is_array_ref ($name)) {
AV *vals = (AV *) SvRV ($name);
$type value = 0;
int i;
for (i=0; i<=av_len(vals); i++)
value |= cairo_${name}_from_sv_part (
SvPV_nolen (*av_fetch (vals, i, 0)));
return value;
}
if (SvPOK ($name))
return cairo_${name}_from_sv_part (SvPV_nolen ($name));
croak ("`%s' is not a valid $type value, expecting a string scalar "
"or an arrayref of strings",
SvPV_nolen ($name));
return 0;
}
SV *
cairo_${name}_to_sv ($type val)
{
AV *flags = newAV ();
$tree_to
return newRV_noinc ((SV *) flags);
}
EOS
if (exists $guards{$type}) {
print FLAGS "#endif /* $guards{$type} */\n";
}
}
close FLAGS;
}
1;