bool ChannelData::canWrite() const { // Duplicated in Data::CanWriteValue(). return amIn() && (canPublish() || (!isBroadcast() && !restricted(Restriction::f_send_messages))); }
static int func_set_code(PyFunctionObject *op, PyObject *value) { PyObject *tmp; Py_ssize_t nfree, nclosure; if (restricted()) return -1; /* Not legal to del f.func_code or to set it to anything * other than a code object. */ if (value == NULL || !PyCode_Check(value)) { PyErr_SetString(PyExc_TypeError, "__code__ must be set to a code object"); return -1; } nfree = PyCode_GetNumFree((PyCodeObject *)value); nclosure = (op->func_closure == NULL ? 0 : PyTuple_GET_SIZE(op->func_closure)); if (nclosure != nfree) { PyErr_Format(PyExc_ValueError, "%s() requires a code object with %zd free vars," " not %zd", PyString_AsString(op->func_name), nclosure, nfree); return -1; } tmp = op->func_code; Py_INCREF(value); op->func_code = value; Py_DECREF(tmp); return 0; }
static int func_set_dict(PyFunctionObject *op, PyObject *value) { PyObject *tmp; if (restricted()) return -1; /* It is illegal to del f.func_dict */ if (value == NULL) { PyErr_SetString(PyExc_TypeError, "function's dictionary may not be deleted"); return -1; } /* Can only set func_dict to a dictionary */ if (!PyDict_Check(value)) { PyErr_SetString(PyExc_TypeError, "setting function's dictionary to a non-dict"); return -1; } tmp = op->func_dict; Py_INCREF(value); op->func_dict = value; Py_XDECREF(tmp); return 0; }
static int func_set_defaults(PyFunctionObject *op, PyObject *value) { PyObject *tmp; if (restricted()) return -1; /* Legal to del f.func_defaults. * Can only set func_defaults to NULL or a tuple. */ if (value == Py_None) value = NULL; if (value != NULL && !PyTuple_Check(value)) { PyErr_SetString(PyExc_TypeError, "__defaults__ must be set to a tuple object"); return -1; } env(-1); jobject jFunc = JyNI_JythonPyObject_FromPyObject(op); jobject jDefaults = JyNI_JythonPyObject_FromPyObject(value); (*env)->CallObjectMethod(env, jFunc, pyFunctionSetFuncDefaults, jDefaults); if ((*env)->ExceptionCheck(env)) { jputs("Exception in func_set_defaults"); (*env)->ExceptionClear(env); return -1; } tmp = op->func_defaults; Py_XINCREF(value); op->func_defaults = value; updateJyGCHeadLink(op, AS_JY_WITH_GC(op), func_defaults_gcindex, value, AS_JY_WITH_GC(value)); Py_XDECREF(tmp); return 0; }
void Server::aggregate (const std::string & survey_in) { Structure survey; survey.load(survey_in); if (POMAGMA_DEBUG_LEVEL > 1) { survey.validate(); } compact(m_structure); if (POMAGMA_DEBUG_LEVEL > 1) { m_structure.validate(); } DenseSet defined = restricted(survey.signature(), m_structure.signature()); size_t total_dim = m_structure.carrier().item_count() + defined.count_items(); if (m_structure.carrier().item_dim() < total_dim) { m_structure.resize(total_dim); if (POMAGMA_DEBUG_LEVEL > 1) { m_structure.validate(); } } pomagma::aggregate(m_structure, survey, defined); if (POMAGMA_DEBUG_LEVEL > 1) { m_structure.validate(); } }
static PyObject * func_get_code(PyFunctionObject *op) { if (restricted()) return NULL; Py_INCREF(op->func_code); return op->func_code; }
/* Return pointer to copy of shell command in the command buffer */ static const char * get_shell_command( const char ** const ibufpp ) { static char * buf = 0; static int bufsz = 0; static char * shcmd = 0; /* shell command buffer */ static int shcmdsz = 0; /* shell command buffer size */ static int shcmdlen = 0; /* shell command length */ const char * p; /* substitution char pointer */ int i = 0, len; if( restricted() ) { set_error_msg( "Shell access restricted" ); return 0; } if( !get_extended_line( ibufpp, &len, true ) ) return 0; p = *ibufpp; if( !resize_buffer( &buf, &bufsz, len + 1 ) ) return 0; buf[i++] = '!'; /* prefix command w/ bang */ while( **ibufpp != '\n' ) { if( **ibufpp == '!' ) { if( p != *ibufpp ) { if( !resize_buffer( &buf, &bufsz, i + 1 ) ) return 0; buf[i++] = *(*ibufpp)++; } else if( !shcmd || ( traditional() && !*( shcmd + 1 ) ) ) { set_error_msg( "No previous command" ); return 0; } else { if( !resize_buffer( &buf, &bufsz, i + shcmdlen ) ) return 0; for( p = shcmd + 1; p < shcmd + shcmdlen; ) buf[i++] = *p++; p = (*ibufpp)++; } } else if( **ibufpp == '%' ) { if( !def_filename[0] ) { set_error_msg( "No current filename" ); return 0; } p = strip_escapes( def_filename ); len = strlen( p ); if( !resize_buffer( &buf, &bufsz, i + len ) ) return 0; while( len-- ) buf[i++] = *p++; p = (*ibufpp)++; } else { if( !resize_buffer( &buf, &bufsz, i + 2 ) ) return 0; buf[i++] = **ibufpp; if( *(*ibufpp)++ == '\\' ) buf[i++] = *(*ibufpp)++; } } while( **ibufpp == '\n' ) ++*ibufpp; /* skip newline */ if( !resize_buffer( &shcmd, &shcmdsz, i + 1 ) ) return 0; memcpy( shcmd, buf, i ); shcmdlen = i; shcmd[i] = 0; if( *p == '!' || *p == '%' ) printf( "%s\n", shcmd + 1 ); return shcmd; }
static PyObject * func_get_defaults(PyFunctionObject *op) { if (restricted()) return NULL; if (op->func_defaults == NULL) { Py_INCREF(Py_None); return Py_None; } Py_INCREF(op->func_defaults); return op->func_defaults; }
static PyObject * func_get_dict(PyFunctionObject *op) { if (restricted()) return NULL; if (op->func_dict == NULL) { op->func_dict = PyDict_New(); if (op->func_dict == NULL) return NULL; } Py_INCREF(op->func_dict); return op->func_dict; }
static int func_set_code(PyFunctionObject *op, PyObject *value) { PyObject *tmp; Py_ssize_t nfree, nclosure; if (restricted()) return -1; /* Not legal to del f.func_code or to set it to anything * other than a code object. */ if (value == NULL || !PyCode_Check(value)) { PyErr_SetString(PyExc_TypeError, "__code__ must be set to a code object"); return -1; } nfree = PyCode_GetNumFree((PyCodeObject *)value); nclosure = (op->func_closure == NULL ? 0 : PyTuple_GET_SIZE(op->func_closure)); if (nclosure != nfree) { PyErr_Format(PyExc_ValueError, "%s() requires a code object with %zd free vars," " not %zd", PyString_AsString(op->func_name), nclosure, nfree); return -1; } env(-1); jobject jFunc = JyNI_JythonPyObject_FromPyObject(op); jobject jCode = JyNI_JythonPyObject_FromPyObject(value); (*env)->CallObjectMethod(env, jFunc, pyFunctionSetCode, jCode); if ((*env)->ExceptionCheck(env)) { jputs("Exception in func_set_code"); (*env)->ExceptionClear(env); return -1; } tmp = op->func_code; Py_INCREF(value); op->func_code = value; updateJyGCHeadLink(op, AS_JY_WITH_GC(op), func_code_gcindex, value, AS_JY_NO_GC(value)); Py_DECREF(tmp); return 0; }
static int func_set_name(PyFunctionObject *op, PyObject *value) { PyObject *tmp; if (restricted()) return -1; /* Not legal to del f.func_name or to set it to anything * other than a string object. */ if (value == NULL || !PyString_Check(value)) { PyErr_SetString(PyExc_TypeError, "__name__ must be set to a string object"); return -1; } tmp = op->func_name; Py_INCREF(value); op->func_name = value; Py_DECREF(tmp); return 0; }
static int func_set_defaults(PyFunctionObject *op, PyObject *value) { PyObject *tmp; if (restricted()) return -1; /* Legal to del f.func_defaults. * Can only set func_defaults to NULL or a tuple. */ if (value == Py_None) value = NULL; if (value != NULL && !PyTuple_Check(value)) { PyErr_SetString(PyExc_TypeError, "__defaults__ must be set to a tuple object"); return -1; } tmp = op->func_defaults; Py_XINCREF(value); op->func_defaults = value; Py_XDECREF(tmp); return 0; }