Skip to content
Commits on Source (51)
1.68.0 - 2021-03-19
-------------------
* Update GLib annotations :mr:`262`
* docs: cleanup :mr:`261`
* Fix syntax errors in gir-1.2.rnc :mr:`256`
1.67.1 - 2021-03-12
-------------------
* Requires Python 3.6+
* Update GLib annotations
* Fix compatibility with Python 3.10 :issue:`358`
* Fix build with GIR data disabled :mr:`248`
* Add test object for signal marshallers :mr:`259`
1.66.1 - 2020-10-03
-------------------
......
......@@ -63,5 +63,5 @@ Bugs should be reported in https://gitlab.gnome.org/GNOME/gobject-introspection/
Contact
-------
:Mail: gtk-devel-list@gnome.org
:IRC: #introspection@irc.gnome.org
\ No newline at end of file
:Discourse: https://discourse.gnome.org/tag/introspection
:IRC: #introspection@irc.gnome.org
......@@ -262,18 +262,18 @@ grammar {
attribute xml:whitespace { "preserve" }?,
## the text of the version of the documentation
text
}?
}? &
## give the stability of the documentation
& element doc-stability {
element doc-stability {
## Preserve the original formatting of the documentation from the source code
attribute xml:space { "preserve" }?,
## Preserve the original formatting of the documentation from the source code. Recommended to use this instead of xml:space
attribute xml:whitespace { "preserve" }?,
## a text value about the stability of the documentation. Usually a simple description like stable or unstable
text
}?
}? &
## documentation of an element
& element doc {
element doc {
## Preserve the original formatting of the documentation from the source code
attribute xml:space { "preserve" }?,
## Keep the whitespace as they were in the source code
......@@ -286,24 +286,24 @@ grammar {
attribute column { xsd:string },
## the text of the documentation
text
}?
}? &
## Deprecated documentation of an element. Kept for historical reasons in general
& element doc-deprecated {
element doc-deprecated {
## Preserve the original formatting of the documentation from the source code
attribute xml:space { "preserve" }?,
## Keep the whitespace as they were in the source code
attribute xml:whitespace { "preserve" }?,
## the text of the deprecated documentation
text
}?
}? &
## Position of the documentation in the original source code
& element source-position {
element source-position {
## File name of the source of the documentation
attribute filename { xsd:string },
## The first line of the documentation in the source code
attribute line { xsd:string },
## The first column of the documentation in the source code
attribute column { xsd:string },
attribute column { xsd:string }
}?
)
......@@ -532,10 +532,10 @@ grammar {
(DocElements
& (AnyType | VarArgs))
}*
}* &
## instance-parameter is a parameter of a C function which is an instance of an existing object. So the callable is surely a method of a class, and this parameter points to the instance of the object. In C++, this would be equivalent to the pointer this which is not passed to the method, in Python it's equivalent to self.
& element instance-parameter {
element instance-parameter {
## name of the instance-parameter
attribute name { xsd:string },
## Binary attribute, true if the parameter can have a null value
......
......@@ -69,5 +69,5 @@ Contact
For questions or additional information, please use:
* Mailing list: gtk-devel-list@gnome.org
* Discourse: https://discourse.gnome.org/tag/introspection
* IRC: #introspection on irc.gnome.org
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -128,7 +128,15 @@ g_constant_info_get_value (GIConstantInfo *info,
if (blob->type.flags.reserved == 0 && blob->type.flags.reserved2 == 0)
{
if (blob->type.flags.pointer)
value->v_pointer = g_memdup (&rinfo->typelib->data[blob->offset], blob->size);
{
#if GLIB_CHECK_VERSION (2, 67, 5)
gsize blob_size = blob->size;
value->v_pointer = g_memdup2 (&rinfo->typelib->data[blob->offset], blob_size);
#else
value->v_pointer = g_memdup (&rinfo->typelib->data[blob->offset], blob->size);
#endif
}
else
{
switch (blob->type.flags.tag)
......
......@@ -20,7 +20,7 @@
import os
builddir = os.environ.get('UNINSTALLED_INTROSPECTION_BUILDDIR')
if builddir is not None:
__path__.append(os.path.join(builddir, 'giscanner'))
__path__.append(os.path.join(builddir, 'giscanner')) # type: ignore # mypy issue #1422
try:
from ._version import __version__
except ImportError:
......
......@@ -110,6 +110,7 @@ import os
import re
import operator
from typing import Tuple
from operator import ne, gt, lt
from collections import namedtuple, Counter, OrderedDict
......@@ -575,7 +576,7 @@ class GtkDocAnnotatable(object):
#: A :class:`tuple` of annotation name constants that are valid for this object. Annotation
#: names not in this :class:`tuple` will be reported as *unknown* by :func:`validate`. The
#: :attr:`valid_annotations` class attribute should be overridden by subclasses.
valid_annotations = ()
valid_annotations = () # type: Tuple[str,...]
def __init__(self, position=None):
#: A :class:`giscanner.message.Position` instance specifying the location of the
......
......@@ -65,7 +65,7 @@ class CacheStore(object):
current_hash = _get_versionhash()
version = os.path.join(self._directory, _CACHE_VERSION_FILENAME)
try:
with open(version, 'r') as version_file:
with open(version, 'r', encoding='utf-8') as version_file:
cache_hash = version_file.read()
except (IOError, OSError) as e:
# File does not exist
......@@ -81,7 +81,7 @@ class CacheStore(object):
tmp_fd, tmp_filename = tempfile.mkstemp(prefix='g-ir-scanner-cache-version-')
try:
with os.fdopen(tmp_fd, 'w') as tmp_file:
with os.fdopen(tmp_fd, 'w', encoding='utf-8') as tmp_file:
tmp_file.write(current_hash)
# On Unix, this would just be os.rename() but Windows
......@@ -169,12 +169,14 @@ class CacheStore(object):
return None
else:
raise
if not self._cache_is_valid(store_filename, filename):
return None
try:
data = pickle.load(fd)
except Exception:
# Broken cache entry, remove it
self._remove_filename(store_filename)
data = None
return data
with fd:
if not self._cache_is_valid(store_filename, filename):
return None
try:
data = pickle.load(fd)
except Exception:
# Broken cache entry, remove it
self._remove_filename(store_filename)
data = None
return data
......@@ -387,7 +387,7 @@ class CCompiler(object):
output_flag = ['-out:' + tmp_filename]
proc = subprocess.call(args + [implib] + output_flag,
stdout=subprocess.PIPE)
with open(tmp_filename, 'r') as tmp_fileobj:
with open(tmp_filename, 'r', encoding='utf-8') as tmp_fileobj:
for line in tmp_fileobj.read().splitlines():
if '__IMPORT_DESCRIPTOR_' in line:
......
......@@ -161,8 +161,8 @@ class CCodeGenerator(object):
self._function_bodies[node] = body
def codegen(self):
self.out_h = open(self.out_h_filename, 'w')
self.out_c = open(self.out_c_filename, 'w')
self.out_h = open(self.out_h_filename, 'w', encoding='utf-8')
self.out_c = open(self.out_c_filename, 'w', encoding='utf-8')
self._codegen_start()
......
......@@ -71,7 +71,7 @@ def doc_main(args):
if args.format == 'sections':
sections_file = generate_sections_file(transformer)
with open(args.output, 'w') as fp:
with open(args.output, 'w', encoding='utf-8') as fp:
write_sections_file(fp, sections_file)
else:
writer = DocWriter(transformer, args.language, args.format)
......
......@@ -111,13 +111,13 @@ class DumpCompiler(object):
'gobject-introspection-1.0', 'gdump.c')
if not os.path.isfile(gdump_path):
raise SystemExit("Couldn't find %r" % (gdump_path, ))
with open(gdump_path) as gdump_file:
with open(gdump_path, encoding='utf-8') as gdump_file:
gdump_contents = gdump_file.read()
tpl_args['gdump_include'] = gdump_contents
tpl_args['init_sections'] = "\n".join(self._options.init_sections)
c_path = self._generate_tempfile(tmpdir, '.c')
with open(c_path, 'w') as f:
with open(c_path, 'w', encoding='utf-8') as f:
f.write(_PROGRAM_TEMPLATE % tpl_args)
# We need to reference our get_type and error_quark functions
......
......@@ -144,7 +144,7 @@ class GDumpParser(object):
"""Load the library (or executable), returning an XML
blob containing data gleaned from GObject's primitive introspection."""
in_path = os.path.join(self._binary.tmpdir, 'functions.txt')
with open(in_path, 'w') as f:
with open(in_path, 'w', encoding='utf-8') as f:
for func in self._get_type_functions:
f.write('get-type:')
f.write(func)
......
......@@ -22,15 +22,12 @@
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include "sourcescanner.h"
#include <glib-object.h>
#ifndef Py_TYPE
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
#endif
#if PY_MAJOR_VERSION >= 3
#define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void)
#define MOD_ERROR_RETURN NULL
......@@ -52,8 +49,12 @@ PyTypeObject Py##cname##_Type = { \
0 \
}
#if PY_VERSION_HEX < 0x030900A4
# define Py_SET_TYPE(obj, type) ((Py_TYPE(obj) = (type)), (void)0)
#endif
#define REGISTER_TYPE(d, name, type) \
Py_TYPE(&type) = &PyType_Type; \
Py_SET_TYPE(&type, &PyType_Type); \
type.tp_alloc = PyType_GenericAlloc; \
type.tp_new = PyType_GenericNew; \
type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE; \
......
# -*- Mode: Python -*-
# GObject-Introspection - a framework for introspecting GObject libraries
# Copyright (C) 2008 Johan Dahlin
#
# 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 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., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
import imp
import os
import sys
from .utils import extract_libtool
class LibtoolImporter(object):
def __init__(self, name, path):
self.name = name
self.path = path
@classmethod
def find_module(cls, name, packagepath=None):
modparts = name.split('.')
filename = modparts.pop() + '.la'
# Given some.package.module 'path' is where subpackages of some.package
# should be looked for. See if we can find a ".libs/module.la" relative
# to those directories and failing that look for file
# "some/package/.libs/module.la" relative to sys.path
if len(modparts) > 0:
modprefix = os.path.join(*modparts)
modprefix = os.path.join(modprefix, '.libs')
else:
modprefix = '.libs'
for path in sys.path:
full = os.path.join(path, modprefix, filename)
if os.path.exists(full):
return cls(name, full)
def load_module(self, name):
realpath = extract_libtool(self.path)
# The first item of the suffix tuple (which can be, depending on platform,
# one or more valid filename extensions used to name c extension modules)
# is ignored by imp.load_module(). Thus, there is no use in pretending it
# is important and we set it to an empty string.
suffix = ('', 'rb', imp.C_EXTENSION)
mod = imp.load_module(name, open(realpath), realpath, suffix)
mod.__loader__ = self
return mod
@classmethod
def __enter__(cls):
sys.meta_path.append(cls)
@classmethod
def __exit__(cls, exc_type, exc_val, exc_tb):
sys.meta_path.remove(cls)
......@@ -13,7 +13,6 @@ giscanner_files = [
'girparser.py',
'girwriter.py',
'gdumpparser.py',
'libtoolimporter.py',
'maintransformer.py',
'mdextensions.py',
'message.py',
......
......@@ -334,7 +334,7 @@ def extract_filelist(options):
filenames = []
if not os.path.exists(options.filelist):
_error('%s: no such filelist file' % (options.filelist, ))
with open(options.filelist, "r") as filelist_file:
with open(options.filelist, "r", encoding=None) as filelist_file:
lines = filelist_file.readlines()
for line in lines:
# We don't support real C++ parsing yet, but we should be able
......@@ -472,6 +472,10 @@ def write_output(data, options):
"""Write encoded XML 'data' to the filename specified in 'options'."""
if options.output == "-":
output = sys.stdout
try:
output.write(data)
except IOError as e:
_error("while writing output: %s" % (e.strerror, ))
elif options.reparse_validate_gir:
main_f, main_f_name = tempfile.mkstemp(suffix='.gir')
......@@ -500,14 +504,10 @@ def write_output(data, options):
return 0
else:
try:
output = open(options.output, 'wb')
with open(options.output, 'wb') as output:
output.write(data)
except IOError as e:
_error("opening output for writing: %s" % (e.strerror, ))
try:
output.write(data)
except IOError as e:
_error("while writing output: %s" % (e.strerror, ))
_error("opening/writing output: %s" % (e.strerror, ))
def get_source_root_dirs(options, filenames):
......