Compare commits

...

3 Commits

Author SHA1 Message Date
Bram Moolenaar
4ce5fe4c87 patch 8.2.1883: compiler warnings when using Python
Problem:    Compiler warnings when using Python.
Solution:   Adjust PyCFunction to also have the second argument.  Use "int"
            return type for some functions.  Insert "(void *)" to get rid of
            the remaining warnings.
2020-10-21 21:01:59 +02:00
Bram Moolenaar
c58f5456e5 patch 8.2.1882: Vim9: v:disallow_let is no longer needed
Problem:    Vim9: v:disallow_let is no longer needed.
Solution:   Remove v:disallow_let.
2020-10-21 20:58:52 +02:00
Bram Moolenaar
692d1a51e7 patch 8.2.1881: cannot build with GTK3
Problem:    Cannot build with GTK3.
Solution:   Adjust form functions.
2020-10-21 17:28:27 +02:00
8 changed files with 82 additions and 74 deletions

View File

@@ -146,7 +146,6 @@ static struct vimvar
{VV_NAME("echospace", VAR_NUMBER), VV_RO},
{VV_NAME("argv", VAR_LIST), VV_RO},
{VV_NAME("collate", VAR_STRING), VV_RO},
{VV_NAME("disallow_let", VAR_NUMBER), 0}, // TODO: remove
};
// shorthand
@@ -243,9 +242,6 @@ evalvars_init(void)
set_vim_var_nr(VV_ECHOSPACE, sc_col - 1);
// TODO: remove later
set_vim_var_nr(VV_DISALLOW_LET, 1);
// Default for v:register is not 0 but '"'. This is adjusted once the
// clipboard has been setup by calling reset_reg_var().
set_reg_var(0);
@@ -749,8 +745,7 @@ ex_let(exarg_T *eap)
ex_finally(eap);
return;
}
if (get_vim_var_nr(VV_DISALLOW_LET)
&& eap->cmdidx == CMD_let && vim9script)
if (eap->cmdidx == CMD_let && vim9script)
{
emsg(_(e_cannot_use_let_in_vim9_script));
return;

View File

@@ -48,8 +48,12 @@ struct _GtkFormChild
};
static void form_class_init(GtkFormClass *klass);
static void form_init(GtkForm *form, void *g_class);
static void gui_gtk_form_class_init(GtkFormClass *klass);
#if GTK_CHECK_VERSION(3,0,0)
static void gui_gtk_form_init(GtkForm *form);
#else
static void gui_gtk_form_init(GtkForm *form, void *g_class);
#endif
static void form_realize(GtkWidget *widget);
static void form_unrealize(GtkWidget *widget);
@@ -195,8 +199,9 @@ gui_gtk_form_thaw(GtkForm *form)
}
// Basic Object handling procedures
#if GTK_CHECK_VERSION(3,0,0)
G_DEFINE_TYPE(GtkForm, gtk_form, GTK_TYPE_CONTAINER)
G_DEFINE_TYPE(GtkForm, gui_gtk_form, GTK_TYPE_CONTAINER)
#else
GtkType
gui_gtk_form_get_type(void)
@@ -211,8 +216,8 @@ gui_gtk_form_get_type(void)
form_info.type_name = "GtkForm";
form_info.object_size = sizeof(GtkForm);
form_info.class_size = sizeof(GtkFormClass);
form_info.class_init_func = (GtkClassInitFunc)form_class_init;
form_info.object_init_func = (GtkObjectInitFunc)form_init;
form_info.class_init_func = (GtkClassInitFunc)gui_gtk_form_class_init;
form_info.object_init_func = (GtkObjectInitFunc)gui_gtk_form_init;
form_type = gtk_type_unique(GTK_TYPE_CONTAINER, &form_info);
}
@@ -221,7 +226,7 @@ gui_gtk_form_get_type(void)
#endif // !GTK_CHECK_VERSION(3,0,0)
static void
form_class_init(GtkFormClass *klass)
gui_gtk_form_class_init(GtkFormClass *klass)
{
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
@@ -254,7 +259,11 @@ form_class_init(GtkFormClass *klass)
}
static void
form_init(GtkForm *form, void *g_class UNUSED)
gui_gtk_form_init(GtkForm *form
#if !GTK_CHECK_VERSION(3,0,0)
, void *g_class UNUSED
#endif
)
{
#if GTK_CHECK_VERSION(3,0,0)
gtk_widget_set_has_window(GTK_WIDGET(form), TRUE);
@@ -416,8 +425,8 @@ form_unrealize(GtkWidget *widget)
}
#if GTK_CHECK_VERSION(3,0,0)
if (GTK_WIDGET_CLASS (gtk_form_parent_class)->unrealize)
(* GTK_WIDGET_CLASS (gtk_form_parent_class)->unrealize) (widget);
if (GTK_WIDGET_CLASS (gui_gtk_form_parent_class)->unrealize)
(* GTK_WIDGET_CLASS (gui_gtk_form_parent_class)->unrealize) (widget);
#else
if (GTK_WIDGET_CLASS (parent_class)->unrealize)
(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
@@ -555,7 +564,7 @@ form_draw(GtkWidget *widget, cairo_t *cr)
}
}
return GTK_WIDGET_CLASS(gtk_form_parent_class)->draw(widget, cr);
return GTK_WIDGET_CLASS(gui_gtk_form_parent_class)->draw(widget, cr);
}
#else // !GTK_CHECK_VERSION(3,0,0)
static gint

View File

@@ -324,7 +324,7 @@ static char *OutputAttrs[] = {
};
static PyObject *
OutputDir(PyObject *self)
OutputDir(PyObject *self, PyObject *args UNUSED)
{
return ObjectDir(self, OutputAttrs);
}
@@ -468,30 +468,33 @@ OutputWritelines(OutputObject *self, PyObject *seq)
}
static PyObject *
AlwaysNone(PyObject *self UNUSED)
AlwaysNone(PyObject *self UNUSED, PyObject *args UNUSED)
{
// do nothing
Py_INCREF(Py_None);
return Py_None;
}
#define ALWAYS_NONE AlwaysNone(NULL, NULL)
static PyObject *
AlwaysFalse(PyObject *self UNUSED)
AlwaysFalse(PyObject *self UNUSED, PyObject *args UNUSED)
{
// do nothing
PyObject *ret = Py_False;
Py_INCREF(ret);
return ret;
}
#define ALWAYS_FALSE AlwaysFalse(NULL, NULL)
static PyObject *
AlwaysTrue(PyObject *self UNUSED)
AlwaysTrue(PyObject *self UNUSED, PyObject *args UNUSED)
{
// do nothing
PyObject *ret = Py_True;
Py_INCREF(ret);
return ret;
}
#define ALWAYS_TRUE AlwaysTrue(NULL, NULL)
/***************/
@@ -1179,7 +1182,7 @@ map_finder_callback(char_u *path, void *_data)
}
static PyObject *
Vim_GetPaths(PyObject *self UNUSED)
Vim_GetPaths(PyObject *self UNUSED, PyObject *args UNUSED)
{
PyObject *ret;
@@ -1209,7 +1212,7 @@ FinderFindSpec(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "s|O", &fullname, &target))
return NULL;
if (!(paths = Vim_GetPaths(self)))
if (!(paths = Vim_GetPaths(self, NULL)))
return NULL;
spec = PyObject_CallFunction(py_find_spec, "sOO", fullname, paths, target);
@@ -1344,7 +1347,7 @@ FinderFindModule(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "s", &fullname))
return NULL;
if (!(new_path = Vim_GetPaths(self)))
if (!(new_path = Vim_GetPaths(self, NULL)))
return NULL;
result = find_module(fullname, fullname, new_path);
@@ -1408,8 +1411,8 @@ static struct PyMethodDef VimMethods[] = {
{"eval", VimEval, METH_VARARGS, "Evaluate an expression using Vim evaluator" },
{"bindeval", VimEvalPy, METH_O, "Like eval(), but returns objects attached to Vim ones"},
{"strwidth", VimStrwidth, METH_O, "Screen string width, counts <Tab> as having width 1"},
{"chdir", (PyCFunction)VimChdir, METH_VARARGS|METH_KEYWORDS, "Change directory"},
{"fchdir", (PyCFunction)VimFchdir, METH_VARARGS|METH_KEYWORDS, "Change directory"},
{"chdir", (PyCFunction)(void *)VimChdir, METH_VARARGS|METH_KEYWORDS, "Change directory"},
{"fchdir", (PyCFunction)(void *)VimFchdir, METH_VARARGS|METH_KEYWORDS, "Change directory"},
{"foreach_rtp", VimForeachRTP, METH_O, "Call given callable for each path in &rtp"},
#if PY_VERSION_HEX >= 0x030700f0
{"find_spec", FinderFindSpec, METH_VARARGS, "Internal use only, returns spec object for any input it receives"},
@@ -1643,7 +1646,7 @@ static char *DictionaryAttrs[] = {
};
static PyObject *
DictionaryDir(PyObject *self)
DictionaryDir(PyObject *self, PyObject *args UNUSED)
{
return ObjectDir(self, DictionaryAttrs);
}
@@ -1850,11 +1853,11 @@ DictionaryIter(DictionaryObject *self)
dii->dii_todo = ht->ht_used;
return IterNew(dii,
(destructorfun) PyMem_Free, (nextfun) DictionaryIterNext,
(destructorfun)(void *) PyMem_Free, (nextfun) DictionaryIterNext,
NULL, NULL, (PyObject *)self);
}
static PyInt
static int
DictionaryAssItem(
DictionaryObject *self, PyObject *keyObject, PyObject *valObject)
{
@@ -1970,7 +1973,7 @@ dict_key(hashitem_T *hi)
}
static PyObject *
DictionaryListKeys(DictionaryObject *self)
DictionaryListKeys(DictionaryObject *self, PyObject *args UNUSED)
{
return DictionaryListObjects(self, dict_key);
}
@@ -1985,7 +1988,7 @@ dict_val(hashitem_T *hi)
}
static PyObject *
DictionaryListValues(DictionaryObject *self)
DictionaryListValues(DictionaryObject *self, PyObject *args UNUSED)
{
return DictionaryListObjects(self, dict_val);
}
@@ -2015,7 +2018,7 @@ dict_item(hashitem_T *hi)
}
static PyObject *
DictionaryListItems(DictionaryObject *self)
DictionaryListItems(DictionaryObject *self, PyObject *args UNUSED)
{
return DictionaryListObjects(self, dict_item);
}
@@ -2166,7 +2169,7 @@ DictionaryPop(DictionaryObject *self, PyObject *args)
}
static PyObject *
DictionaryPopItem(DictionaryObject *self)
DictionaryPopItem(DictionaryObject *self, PyObject *args UNUSED)
{
hashitem_T *hi;
PyObject *ret;
@@ -2229,7 +2232,7 @@ static struct PyMethodDef DictionaryMethods[] = {
{"keys", (PyCFunction)DictionaryListKeys, METH_NOARGS, ""},
{"values", (PyCFunction)DictionaryListValues, METH_NOARGS, ""},
{"items", (PyCFunction)DictionaryListItems, METH_NOARGS, ""},
{"update", (PyCFunction)DictionaryUpdate, METH_VARARGS|METH_KEYWORDS, ""},
{"update", (PyCFunction)(void *)DictionaryUpdate, METH_VARARGS|METH_KEYWORDS, ""},
{"get", (PyCFunction)DictionaryGet, METH_VARARGS, ""},
{"pop", (PyCFunction)DictionaryPop, METH_VARARGS, ""},
{"popitem", (PyCFunction)DictionaryPopItem, METH_NOARGS, ""},
@@ -2742,21 +2745,21 @@ ListAssIndex(ListObject *self, Py_ssize_t index, PyObject *obj)
return 0;
}
static Py_ssize_t
static int
ListAssItem(ListObject *self, PyObject *idx, PyObject *obj)
{
#if PY_MAJOR_VERSION < 3
if (PyInt_Check(idx))
{
long _idx = PyInt_AsLong(idx);
return ListAssIndex(self, _idx, obj);
return (int)ListAssIndex(self, _idx, obj);
}
else
#endif
if (PyLong_Check(idx))
{
long _idx = PyLong_AsLong(idx);
return ListAssIndex(self, _idx, obj);
return (int)ListAssIndex(self, _idx, obj);
}
else if (PySlice_Check(idx))
{
@@ -2765,7 +2768,7 @@ ListAssItem(ListObject *self, PyObject *idx, PyObject *obj)
if (PySlice_GetIndicesEx((PySliceObject_T *)idx, ListLength(self),
&start, &stop, &step, &slicelen) < 0)
return -1;
return ListAssSlice(self, start, step, slicelen,
return (int)ListAssSlice(self, start, step, slicelen,
obj);
}
else
@@ -2858,7 +2861,7 @@ static char *ListAttrs[] = {
};
static PyObject *
ListDir(PyObject *self)
ListDir(PyObject *self, PyObject *args UNUSED)
{
return ObjectDir(self, ListAttrs);
}
@@ -3113,7 +3116,7 @@ static char *FunctionAttrs[] = {
};
static PyObject *
FunctionDir(PyObject *self)
FunctionDir(PyObject *self, PyObject *args UNUSED)
{
return ObjectDir(self, FunctionAttrs);
}
@@ -3128,7 +3131,7 @@ FunctionAttr(FunctionObject *self, char *name)
else if (strcmp(name, "args") == 0)
{
if (self->argv == NULL || (list = list_alloc()) == NULL)
return AlwaysNone(NULL);
return ALWAYS_NONE;
for (i = 0; i < self->argc; ++i)
list_append_tv(list, &self->argv[i]);
@@ -3136,12 +3139,12 @@ FunctionAttr(FunctionObject *self, char *name)
}
else if (strcmp(name, "self") == 0)
return self->self == NULL
? AlwaysNone(NULL)
? ALWAYS_NONE
: NEW_DICTIONARY(self->self);
else if (strcmp(name, "auto_rebind") == 0)
return self->auto_rebind
? AlwaysTrue(NULL)
: AlwaysFalse(NULL);
? ALWAYS_TRUE
: ALWAYS_FALSE;
else if (strcmp(name, "__members__") == 0)
return ObjectDir(NULL, FunctionAttrs);
return NULL;
@@ -3497,7 +3500,7 @@ OptionsIter(OptionsObject *self)
oii->lastoption = NULL;
return IterNew(oii,
(destructorfun) PyMem_Free, (nextfun) OptionsIterNext,
(destructorfun)(void *) PyMem_Free, (nextfun) OptionsIterNext,
NULL, NULL, (PyObject *)self);
}
@@ -3742,7 +3745,7 @@ static char *TabPageAttrs[] = {
};
static PyObject *
TabPageDir(PyObject *self)
TabPageDir(PyObject *self, PyObject *args UNUSED)
{
return ObjectDir(self, TabPageAttrs);
}
@@ -3968,7 +3971,7 @@ static char *WindowAttrs[] = {
};
static PyObject *
WindowDir(PyObject *self)
WindowDir(PyObject *self, PyObject *args UNUSED)
{
return ObjectDir(self, WindowAttrs);
}
@@ -5106,7 +5109,7 @@ static char *RangeAttrs[] = {
};
static PyObject *
RangeDir(PyObject *self)
RangeDir(PyObject *self, PyObject *args UNUSED)
{
return ObjectDir(self, RangeAttrs);
}
@@ -5223,7 +5226,7 @@ static char *BufferAttrs[] = {
};
static PyObject *
BufferDir(PyObject *self)
BufferDir(PyObject *self, PyObject *args UNUSED)
{
return ObjectDir(self, BufferAttrs);
}
@@ -5520,7 +5523,7 @@ static char *CurrentAttrs[] = {
};
static PyObject *
CurrentDir(PyObject *self)
CurrentDir(PyObject *self, PyObject *args UNUSED)
{
return ObjectDir(self, CurrentAttrs);
}
@@ -6424,10 +6427,10 @@ ConvertToPyObject(typval_T *tv)
case VAR_SPECIAL:
switch (tv->vval.v_number)
{
case VVAL_FALSE: return AlwaysFalse(NULL);
case VVAL_TRUE: return AlwaysTrue(NULL);
case VVAL_FALSE: return ALWAYS_FALSE;
case VVAL_TRUE: return ALWAYS_TRUE;
case VVAL_NONE:
case VVAL_NULL: return AlwaysNone(NULL);
case VVAL_NULL: return ALWAYS_NONE;
}
PyErr_SET_VIM(N_("internal error: invalid value type"));
return NULL;

View File

@@ -1197,16 +1197,16 @@ OutputGetattr(PyObject *self, char *name)
#define BufferType_Check(obj) ((obj)->ob_type == &BufferType)
static PyInt BufferAssItem(PyObject *, PyInt, PyObject *);
static PyInt BufferAssSlice(PyObject *, PyInt, PyInt, PyObject *);
static int BufferAssItem(PyObject *, PyInt, PyObject *);
static int BufferAssSlice(PyObject *, PyInt, PyInt, PyObject *);
// Line range type - Implementation functions
// --------------------------------------
#define RangeType_Check(obj) ((obj)->ob_type == &RangeType)
static PyInt RangeAssItem(PyObject *, PyInt, PyObject *);
static PyInt RangeAssSlice(PyObject *, PyInt, PyInt, PyObject *);
static int RangeAssItem(PyObject *, PyInt, PyObject *);
static int RangeAssSlice(PyObject *, PyInt, PyInt, PyObject *);
// Current objects type - Implementation functions
// -----------------------------------------------
@@ -1246,13 +1246,13 @@ BufferGetattr(PyObject *self, char *name)
//////////////////
static PyInt
static int
BufferAssItem(PyObject *self, PyInt n, PyObject *val)
{
return RBAsItem((BufferObject *)(self), n, val, 1, -1, NULL);
}
static PyInt
static int
BufferAssSlice(PyObject *self, PyInt lo, PyInt hi, PyObject *val)
{
return RBAsSlice((BufferObject *)(self), lo, hi, val, 1, -1, NULL);
@@ -1290,7 +1290,7 @@ RangeGetattr(PyObject *self, char *name)
////////////////
static PyInt
static int
RangeAssItem(PyObject *self, PyInt n, PyObject *val)
{
return RBAsItem(((RangeObject *)(self))->buf, n, val,
@@ -1299,7 +1299,7 @@ RangeAssItem(PyObject *self, PyInt n, PyObject *val)
&((RangeObject *)(self))->end);
}
static PyInt
static int
RangeAssSlice(PyObject *self, PyInt lo, PyInt hi, PyObject *val)
{
return RBAsSlice(((RangeObject *)(self))->buf, lo, hi, val,

View File

@@ -1252,7 +1252,7 @@ OutputSetattro(PyObject *self, PyObject *nameobj, PyObject *val)
#define BufferType_Check(obj) ((obj)->ob_base.ob_type == &BufferType)
static PyObject* BufferSubscript(PyObject *self, PyObject *idx);
static Py_ssize_t BufferAsSubscript(PyObject *self, PyObject *idx, PyObject *val);
static int BufferAsSubscript(PyObject *self, PyObject *idx, PyObject *val);
// Line range type - Implementation functions
// --------------------------------------
@@ -1260,8 +1260,8 @@ static Py_ssize_t BufferAsSubscript(PyObject *self, PyObject *idx, PyObject *val
#define RangeType_Check(obj) ((obj)->ob_base.ob_type == &RangeType)
static PyObject* RangeSubscript(PyObject *self, PyObject *idx);
static Py_ssize_t RangeAsItem(PyObject *, Py_ssize_t, PyObject *);
static Py_ssize_t RangeAsSubscript(PyObject *self, PyObject *idx, PyObject *val);
static int RangeAsItem(PyObject *, Py_ssize_t, PyObject *);
static int RangeAsSubscript(PyObject *self, PyObject *idx, PyObject *val);
// Current objects type - Implementation functions
// -----------------------------------------------
@@ -1346,7 +1346,7 @@ BufferSubscript(PyObject *self, PyObject* idx)
}
}
static Py_ssize_t
static int
BufferAsSubscript(PyObject *self, PyObject* idx, PyObject* val)
{
if (PyLong_Check(idx))
@@ -1418,7 +1418,7 @@ RangeGetattro(PyObject *self, PyObject *nameobj)
////////////////
static Py_ssize_t
static int
RangeAsItem(PyObject *self, Py_ssize_t n, PyObject *val)
{
return RBAsItem(((RangeObject *)(self))->buf, n, val,
@@ -1461,7 +1461,7 @@ RangeSubscript(PyObject *self, PyObject* idx)
}
}
static Py_ssize_t
static int
RangeAsSubscript(PyObject *self, PyObject *idx, PyObject *val)
{
if (PyLong_Check(idx))

View File

@@ -750,6 +750,12 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1883,
/**/
1882,
/**/
1881,
/**/
1880,
/**/

View File

@@ -1994,8 +1994,7 @@ typedef int sock_T;
#define VV_ECHOSPACE 93
#define VV_ARGV 94
#define VV_COLLATE 95
#define VV_DISALLOW_LET 96 // TODO: remove again
#define VV_LEN 97 // number of v: vars
#define VV_LEN 96 // number of v: vars
// used for v_number in VAR_BOOL and VAR_SPECIAL
#define VVAL_FALSE 0L // VAR_BOOL

View File

@@ -7319,12 +7319,8 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
break;
case CMD_let:
if (get_vim_var_nr(VV_DISALLOW_LET))
{
emsg(_(e_cannot_use_let_in_vim9_script));
break;
}
// FALLTHROUGH
emsg(_(e_cannot_use_let_in_vim9_script));
break;
case CMD_var:
case CMD_final:
case CMD_const: