Skip to content
Snippets Groups Projects
Select Git revision
  • fe1a0e71c948a96028f53911e25c6929c19032fe
  • branchX default protected
  • Inventory
  • UIControls
  • fsv2
  • tonetest
  • from_nb
  • tonemapping
  • opt-shadows
  • BX-634
  • xCSG
  • hc
  • gizmos
  • gui2CSSLexer
  • msExporter
  • gui2
  • gui2Fix
  • master protected
  • pk
  • mesh_optimize
  • light_wip
  • version_X.11.2 protected
  • version_X.11.1 protected
  • version_X.11.1-dev protected
  • version_X.11.0-dev protected
  • version_X.10.1 protected
  • version_X.10.1-dev protected
  • version_X.10.0-dev protected
  • version_X.9.5 protected
  • version_X.9.4 protected
  • version_X.9.3 protected
  • version_X.9.3-dev protected
  • version_X.9.2-dev protected
  • version_X.9.1-dev protected
  • version_X.9.0-dev protected
  • version_X.8.2 protected
  • version_X.8.2-dev protected
  • version_X.8.1-dev protected
  • version_X.8.0-dev protected
  • version_X.7.1 protected
  • version_X.7.0 protected
41 results

LightSystem.cpp

Blame
  • boolobject.c 7.08 KiB
    /* Boolean type, a subtype of int */
    
    #include "Python.h"
    #include "pycore_object.h"      // _Py_FatalRefcountError()
    #include "pycore_runtime.h"       // _Py_ID()
    
    /* We define bool_repr to return "False" or "True" */
    
    static PyObject *
    bool_repr(PyObject *self)
    {
        PyObject *res = self == Py_True ? &_Py_ID(True) : &_Py_ID(False);
        return Py_NewRef(res);
    }
    
    /* Function to return a bool from a C long */
    
    PyObject *PyBool_FromLong(long ok)
    {
        PyObject *result;
    
        if (ok)
            result = Py_True;
        else
            result = Py_False;
        Py_INCREF(result);
        return result;
    }
    
    /* We define bool_new to always return either Py_True or Py_False */
    
    static PyObject *
    bool_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
    {
        PyObject *x = Py_False;
        long ok;
    
        if (!_PyArg_NoKeywords("bool", kwds))
            return NULL;
        if (!PyArg_UnpackTuple(args, "bool", 0, 1, &x))
            return NULL;
        ok = PyObject_IsTrue(x);
        if (ok < 0)
            return NULL;
        return PyBool_FromLong(ok);
    }
    
    static PyObject *
    bool_vectorcall(PyObject *type, PyObject * const*args,
                    size_t nargsf, PyObject *kwnames)
    {
        long ok = 0;
        if (!_PyArg_NoKwnames("bool", kwnames)) {
            return NULL;
        }
    
        Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
        if (!_PyArg_CheckPositional("bool", nargs, 0, 1)) {
            return NULL;
        }
    
        assert(PyType_Check(type));
        if (nargs) {
            ok = PyObject_IsTrue(args[0]);
            if (ok < 0) {
                return NULL;
            }
        }
        return PyBool_FromLong(ok);
    }