コード例 #1
0
ファイル: CompiledMethodType.cpp プロジェクト: Wkryst/Nuitka
 // tp_repr slot, decide how a function shall be output
static PyObject *Nuitka_Method_tp_repr( Nuitka_MethodObject *method )
{
    if ( method->m_object == NULL )
    {
#if PYTHON_VERSION < 300
        return PyString_FromFormat(
            "<unbound compiled_method %s.%s>",
            GET_CLASS_NAME( method->m_class ),
            Nuitka_String_AsString( method->m_function->m_name )
        );
#else
        return PyUnicode_FromFormat(
            "<compiled function %s at %p>",
            Nuitka_String_AsString( method->m_function->m_name ),
            method->m_function
        );
#endif
    }
    else
    {
        // Note: CPython uses repr ob the object, although a comment despises
        // it, we do it for compatibility.
        PyObject *object_repr = PyObject_Repr( method->m_object );

        if ( object_repr == NULL )
        {
            return NULL;
        }
#if PYTHON_VERSION < 300
        else if ( !PyString_Check( object_repr ) )
        {
            Py_DECREF( object_repr );
            return NULL;
        }
#else
        else if ( !PyUnicode_Check( object_repr ) )
        {
            Py_DECREF( object_repr );
            return NULL;
        }
#endif

#if PYTHON_VERSION < 300
        PyObject *result = PyString_FromFormat(
#else
        PyObject *result = PyUnicode_FromFormat(
#endif
            "<bound compiled_method %s.%s of %s>",
            GET_CLASS_NAME( method->m_class ),
            Nuitka_String_AsString( method->m_function->m_name ),
            Nuitka_String_AsString_Unchecked( object_repr )
        );

        Py_DECREF( object_repr );

        return result;
    }
}
コード例 #2
0
ファイル: CompiledMethodType.c プロジェクト: fluxer/spm
static PyObject *Nuitka_Method_tp_call( struct Nuitka_MethodObject *method, PyObject *args, PyObject *kw )
{
    Py_ssize_t arg_count = PyTuple_Size( args );

    if ( method->m_object == NULL )
    {
        if (unlikely( arg_count < 1 ))
        {
            PyErr_Format(
                PyExc_TypeError,
                "unbound compiled_method %s%s must be called with %s instance as first argument (got nothing instead)",
                GET_CALLABLE_NAME( (PyObject *)method->m_function ),
                GET_CALLABLE_DESC( (PyObject *)method->m_function ),
                GET_CLASS_NAME( method->m_class )
            );
            return NULL;
        }
        else
        {
            PyObject *self = PyTuple_GET_ITEM( args, 0 );
            CHECK_OBJECT( self );

            int result = PyObject_IsInstance( self, method->m_class );

            if (unlikely( result < 0 ))
            {
                return NULL;
            }
            else if (unlikely( result == 0 ))
            {
                PyErr_Format(
                    PyExc_TypeError,
                    "unbound compiled_method %s%s must be called with %s instance as first argument (got %s instance instead)",
                    GET_CALLABLE_NAME( (PyObject *)method->m_function ),
                    GET_CALLABLE_DESC( (PyObject *)method->m_function ),
                    GET_CLASS_NAME( method->m_class ),
                    GET_INSTANCE_CLASS_NAME( (PyObject *)self )
                );

                return NULL;
            }
        }

        return Py_TYPE( method->m_function )->tp_call(
            (PyObject *)method->m_function, args, kw
        );
    }
    else
    {
        return Nuitka_CallMethodFunctionPosArgsKwArgs(
            method->m_function,
            method->m_object,
            &PyTuple_GET_ITEM( args, 0 ),
            arg_count,
            kw
        );
    }
}
コード例 #3
0
ファイル: CompiledMethodType.cpp プロジェクト: Wkryst/Nuitka
static char const *GET_INSTANCE_CLASS_NAME( PyObject *instance )
{
    PyObject *klass = PyObject_GetAttrString( instance, "__class__" );

    // Fallback to type as this cannot fail.
    if ( klass == NULL )
    {
        PyErr_Clear();
        klass = INCREASE_REFCOUNT( (PyObject *)Py_TYPE( instance ) );
    }

    char const *result = GET_CLASS_NAME( klass );

    Py_DECREF( klass );

    return result;
}
コード例 #4
0
ファイル: CompiledMethodType.c プロジェクト: fluxer/spm
static char const *GET_INSTANCE_CLASS_NAME( PyObject *instance )
{
    // TODO: We have a constant for that already.
    PyObject *klass = PyObject_GetAttrString( instance, "__class__" );

    // Fallback to type as this cannot fail.
    if ( klass == NULL )
    {
        CLEAR_ERROR_OCCURRED();
        klass = INCREASE_REFCOUNT( (PyObject *)Py_TYPE( instance ) );
    }

    char const *result = GET_CLASS_NAME( klass );

    Py_DECREF( klass );

    return result;
}
コード例 #5
0
NF_EXPORT void DllStartPlugin(NFIPluginManager* pm)
{
#if NF_PLATFORM == NF_PLATFORM_WIN
    SetConsoleTitle("NFLoginServer");
#endif
    CREATE_PLUGIN(pm, NFLoginLogicPlugin)

};

NF_EXPORT void DllStopPlugin(NFIPluginManager* pm)
{
    DESTROY_PLUGIN(pm, NFLoginLogicPlugin)
};

#endif
//////////////////////////////////////////////////////////////////////////

const int NFLoginLogicPlugin::GetPluginVersion()
{
    return 0;
}

const std::string NFLoginLogicPlugin::GetPluginName()
{
    return GET_CLASS_NAME(NFLoginLogicPlugin);
}

void NFLoginLogicPlugin::Install()
{

    REGISTER_MODULE(pPluginManager, NFILoginLogicModule, NFCLoginLogicModule)

}

void NFLoginLogicPlugin::Uninstall()
{
    UNREGISTER_MODULE(pPluginManager, NFILoginLogicModule, NFCLoginLogicModule)
}
コード例 #6
0
const std::string NFWorldLogicPlugin::GetPluginName()
{
    return GET_CLASS_NAME(NFWorldLogicPlugin);
}
コード例 #7
0
ファイル: Tutorial1.cpp プロジェクト: ketoo/NoahGameFrame
const std::string Tutorial1::GetPluginName()
{
    return GET_CLASS_NAME(Tutorial1);
}
コード例 #8
0
ファイル: NFScalePlugin.cpp プロジェクト: ketoo/NoahGameFrame
const std::string NFScalePlugin::GetPluginName()
{
	return GET_CLASS_NAME(NFScalePlugin);
}
コード例 #9
0
ファイル: errors.c プロジェクト: cosyverif/deb-greatspn
void out_error(int  code,  int  pl,  int  tr,  int  cl,  int  sb,  char  *name1,  char  *name2)
 {/* Init out_error */
  fprintf(stdout,"\nERROR : ");
  switch(code)
   {/* Tipo di errore */
#ifdef SWN
    case ERROR_UNKNOWN_FUNCTION_TYPE :
    fprintf(stdout,"unknown arc type from transition %s to place %s\n",
		    TRANS_NAME(tr),PLACE_NAME(pl));
	    break;
#endif
    case ERROR_LOW_MAX_TRANS :
    fprintf(stdout,"increase constant MAX_TRANS\n");
	    break;
#ifdef SWN
    case ERROR_LOW_MAX_PLACE :
    fprintf(stdout,"increase constant MAX_PLACE_DOMAIN due to place %s\n",
		    PLACE_NAME(pl));
	    break;
    case ERROR_LOW_MAX_DOMAIN :
    fprintf(stdout,"increase constant MAX_DOMAIN due to transition %s\n",
		    TRANS_NAME(tr));
	    break;
    case ERROR_LOW_MAX_COL_RIP :
    fprintf(stdout,"increase constant MAX_COL_RIP due to transition %s\n",
		    TRANS_NAME(tr));
	    break;
#endif
    case ERROR_INITIAL_DEAD_MARKING :
    fprintf(stdout,"initial dead marking !\n");
	    break;
    case ERROR_INITIAL_VANISHING_MARKING :
    fprintf(stdout,"initial vanishing marking !\n");
	    break;
#ifdef SIMULATION
    case ERROR_DEAD_MARKING :
    fprintf(stdout,"Dead marking reached at simulation step %d\n",events_made);
    out_cur_simulation_state(stdout);
    fprintf(stdout,"Set trace option.\n");
	    break;
#endif
#ifdef SIMULATION
    case ERROR_NEGATIVE_MARKING	:
    fprintf(stdout,"negative marking of place %s due to transition %s occurred at step %d\n",
		    PLACE_NAME(pl),TRANS_NAME(tr),events_made);
#else
    case ERROR_NEGATIVE_MARKING	:
    fprintf(stdout,"negative marking of place %s due to transition %s \n", PLACE_NAME(pl),TRANS_NAME(tr));
#endif
	    break;
    case ERROR_UNKNOWN_PLACE_NAME :
    fprintf(stdout,"unknown place name %s in file .stat\n",name1);
	    break;
    case ERROR_UNKNOWN_TRANSITION_NAME :
    fprintf(stdout,"unknown transition name %s in file .stat\n",name1);
	    break;
#ifdef SWN
    case ERROR_UNKNOWN_STATIC_SUBCLASS_NAME :
    fprintf(stdout,"unknown static subclass name %s\n",name1);
	    break;
    case ERROR_REDECLARATION :
    fprintf(stdout,"redeclaration of static subclass %s of class %s \n",
		    name1,GET_CLASS_NAME(cl));
	    break;
    case ERROR_INTERSECTION :
    fprintf(stdout,"static subclasses %s and %s of class %s are not disjoint\n",
		    name1,name2,GET_CLASS_NAME(cl));
	    break;
    case ERROR_INCOMPLETE_DEFINITION :
    fprintf(stdout,"incomplete static subclasses definition\n");
	    break;
    case ERROR_UNEXISTING_SUBCLASS_IN_DYNAMIC :
    fprintf(stdout,"static subclass %s does not exist in declaration of dynamic subclass %s\n",
		    name1,name2);
	    break;
    case ERROR_REDECLARATION_DYNAMIC :
    fprintf(stdout,"dynamic subclass redeclaration (%s) of static subclass %s\n",
		    name1,name2);
	    break;
    case ERROR_INCONSISTENT_CARDINALITIES :
    fprintf(stdout,"sum of cardinalities of dynamic subclasses of static subclass %s exceeds cardinality of class %s\n",
		    GET_STATIC_NAME(cl,sb),GET_CLASS_NAME(cl));
	    break;
    case ERROR_REPETITIONS_AND_NO_FUNCTION :
    fprintf(stdout,"color domain of place %s has color repetitions\n",
		    PLACE_NAME(pl));
    fprintf(stdout,"but the arc to (from) transition %s has no associated function\n",
		    TRANS_NAME(tr));
	    break;
    case ERROR_AMBIGUOUS_DEFINITION :
    fprintf(stdout,"ambiguous definition for the arc from place %s to transition %s\n",
		    PLACE_NAME(pl),TRANS_NAME(tr));
	    break;
    case ERROR_UNKNOWN_PLACE_IN_FUNCTION :
    fprintf(stdout,"unknown place name %s in function from place %s to transition %s\n",
		    name1,PLACE_NAME(pl),TRANS_NAME(tr));
	    break;
    case ERROR_NEUTRAL_PLACE_AND_FUNCTION :
    fprintf(stdout,"color function on arc from neutral place %s to transition %s\n",
		    PLACE_NAME(pl),TRANS_NAME(tr));
	    break;
    case ERROR_UNEXISTING_CLASS	:
    fprintf(stdout,"colour class %s does not exist in colour domain of place %s\n",
		    name1,PLACE_NAME(pl));
	    break;
    case ERROR_CLASS_REDECLARATION :
    fprintf(stdout,"colour class %s has been redeclared\n",name1);
	    break;
    case ERROR_TWICE_THE_SAME_STATIC :
    fprintf(stdout,"static subclass %s has been declared twice\n",name1);
	    break;
    case ERROR_REDEFINITION :
    fprintf(stdout,"redefinition of static subclass %s of class %s \n",
		    GET_STATIC_NAME(cl,sb),GET_CLASS_NAME(cl));
	    break;
    case ERROR_OBJECT_DESCRIPTION :
    fprintf(stdout,"incorrect objects description of static subclass %s\n",name1);
	    break;
    case ERROR_OBJECT_REDECLARATION :
    fprintf(stdout,"object %s has been redeclared\n",name1);
	    break;
    case ERROR_DYNAMIC_REDECLARATION :
    fprintf(stdout,"dynamic subclass %s has been redeclared\n",name1);
	    break;
    case ERROR_MISSING_CLASS :
    fprintf(stdout,"colour class %s has not been declared\n",name1);
	    break;
    case ERROR_MISSING_STATIC :
    fprintf(stdout,"static subclass %s has not been declared\n",name1);
	    break;
    case ERROR_LESSER_MARKING_COMPONENTS :
    fprintf(stdout,"wrong number components (<) for marking of place %s\n",
		    PLACE_NAME(pl));
	    break;
    case ERROR_GREATER_MARKING_COMPONENTS :
    fprintf(stdout,"wrong number components (>) for marking of place %s\n",
		    PLACE_NAME(pl));
	    break;
    case ERROR_UNKNOWN_ELEMENT_IN_MARKING :
#ifdef SYMBOLIC
    fprintf(stdout,"unknown dynamic subclass %s in marking of place %s of class %s\n",
		    name1,PLACE_NAME(pl),GET_CLASS_NAME(cl));
#endif
#ifdef COLOURED
    fprintf(stdout,"unknown object %s in marking of place %s of class %s\n",
		    name1,PLACE_NAME(pl),GET_CLASS_NAME(cl));
#endif
	    break;
    case ERROR_LESSER_FUNCTION_COMPONENTS :
    fprintf(stdout,"number components (<) for function of place %s and transition %s\n",
		    PLACE_NAME(pl),TRANS_NAME(tr));
	    break;
    case ERROR_GREATER_FUNCTION_COMPONENTS :
    fprintf(stdout,"number components (>) for function of place %s and transition %s\n",
		    PLACE_NAME(pl),TRANS_NAME(tr));
	    break;
    case ERROR_WRONG_STATIC_INDEX_IN_MARKING :
    fprintf(stdout,"out of range index for class %s in marking of place %s\n",
	     GET_CLASS_NAME(cl),PLACE_NAME(pl));
	    break;
    case ERROR_WRONG_STATIC_NAME_IN_MARKING:
    fprintf(stdout,"unknown static subclass name %s of class %s in marking of place %s\n",
		    name1,GET_CLASS_NAME(cl),PLACE_NAME(pl));
	    break;
    case ERROR_WRONG_STATIC_INDEX_IN_FUNCTION :
    fprintf(stdout,"out of range index for class %s in function of place %s and transition %s\n",
	     GET_CLASS_NAME(cl),PLACE_NAME(pl),TRANS_NAME(tr));
	    break;
    case ERROR_WRONG_STATIC_NAME_IN_FUNCTION:
    fprintf(stdout,"unknown static subclass name %s of class %s in function of place %s and transition %s\n",
		    name1,GET_CLASS_NAME(cl),PLACE_NAME(pl),TRANS_NAME(tr));
	    break;
    case ERROR_AMBIGUOUS_ID :
    fprintf(stdout,"ambiguous use of ID for arc function from place %s to transition %s\n",
		    PLACE_NAME(pl),TRANS_NAME(tr));
	    break;
    case ERROR_ILLEGAL_PREDECESSOR :
    fprintf(stdout,"illegal use of predecessor for class %s function in function of place %s and transition %s\n" ,
		    GET_CLASS_NAME(cl),PLACE_NAME(pl),TRANS_NAME(tr));
	    break;
    case ERROR_ILLEGAL_SUCCESSOR :
    fprintf(stdout,"illegal use of successor for class %s function in function of place %s and transition %s\n" ,
		    GET_CLASS_NAME(cl),PLACE_NAME(pl),TRANS_NAME(tr));
	    break;
    case ERROR_UNKNOWN_STATIC_IN_PREDICATE :
    fprintf(stdout,"unknown static subclass %s in a predicate\n",name1);
	    break;
#endif
    case ERROR_NEGATIVE_INITIAL_MARKING	:
    fprintf(stdout,"negative initial marking of place %s\n",PLACE_NAME(pl));
	    break;
    case ERROR_MISSING_MDRATE_DEFINITION :
    fprintf(stdout,"marking dependent rate definition of transition %s does not exist\n",
		    TRANS_NAME(tr));
	    break;
#ifdef SWN
    case ERROR_SHARED_NAME :
    fprintf(stdout,"function name \"%s\" used by different colour classes in function of place %s and transition %s\n",
		    name1,PLACE_NAME(pl),TRANS_NAME(tr));
	    break;
    case ERROR_AMBIGUITY_IN_ARC:
    fprintf(stdout,"ambiguous identity or empty arc for place %s and transition %s\n",
		    PLACE_NAME(pl),TRANS_NAME(tr));
	    break;
#endif
    case ERROR_MARKING_CODING:
    fprintf(stdout,"marking of place %s >= 255\n",PLACE_NAME(pl));
	    break;
    case ERROR_UNKNOWN_MARKING_PARAMETER :
    fprintf(stdout,"unknown marking parameter \"%s\" in function of place %s and transition %s\n",
		    name1,PLACE_NAME(pl),TRANS_NAME(tr));
	    break;
    case ERROR_UNKNOWN_PLACE_IN_PREDICATE :
    fprintf(stdout,"unknown place name %s in a predicate\n",name1);
	    break;
    default :
    fprintf(stdout,"unknown error code %d\n",code);
	    break;
   }/* Tipo di errore */
  exit(1);
 }/* End out_error */
コード例 #10
0
const std::string NFMasterServerPlugin::GetPluginName()
{
	return GET_CLASS_NAME(NFMasterServerPlugin);
}
コード例 #11
0
const std::string NFGameServerNet_ServerPlugin::GetPluginName()
{
	return GET_CLASS_NAME(NFGameServerNet_ServerPlugin);
}
コード例 #12
0
const std::string NFMysqlClusterPlugin::GetPluginName()
{
	return GET_CLASS_NAME(NFMysqlClusterPlugin);
}
コード例 #13
0
const std::string NFLuaScriptPlugin::GetPluginName()
{
	return GET_CLASS_NAME(NFLuaScriptPlugin);
}
コード例 #14
0
const std::string NFLoginNet_HttpServerPlugin::GetPluginName()
{
	return GET_CLASS_NAME(NFLoginNet_HttpServerPlugin);
}
コード例 #15
0
ファイル: CompiledMethodType.cpp プロジェクト: Wkryst/Nuitka
static PyObject *Nuitka_Method_tp_call( Nuitka_MethodObject *method, PyObject *args, PyObject *kw )
{
    int arg_count = int( PyTuple_Size( args ) );

    if ( method->m_object == NULL )
    {
        if (unlikely( arg_count < 1 ))
        {
            PyErr_Format(
                PyExc_TypeError,
                "unbound compiled_method %s%s must be called with %s instance as first argument (got nothing instead)",
                GET_CALLABLE_NAME( (PyObject *)method->m_function ),
                GET_CALLABLE_DESC( (PyObject *)method->m_function ),
                GET_CLASS_NAME( method->m_class )
            );
            return NULL;
        }
        else
        {
            PyObject *self = PyTuple_GET_ITEM( args, 0 );
            assertObject( self );

            int result = PyObject_IsInstance( self, method->m_class );

            if (unlikely( result < 0 ))
            {
                return NULL;
            }
            else if (unlikely( result == 0 ))
            {
                PyErr_Format(
                    PyExc_TypeError,
                    "unbound compiled_method %s%s must be called with %s instance as first argument (got %s instance instead)",
                    GET_CALLABLE_NAME( (PyObject *)method->m_function ),
                    GET_CALLABLE_DESC( (PyObject *)method->m_function ),
                    GET_CLASS_NAME( method->m_class ),
                    GET_INSTANCE_CLASS_NAME( (PyObject *)self )
                );

                return NULL;
            }
        }

        return Py_TYPE( method->m_function )->tp_call(
            (PyObject *)method->m_function, args, kw
        );
    }
    else
    {
#ifdef _MSC_VER
        PyObject **new_args = (PyObject **)_alloca( sizeof( PyObject * ) *( arg_count + 1 ) );
#else
        PyObject *new_args[ arg_count + 1 ];
#endif
        new_args[ 0 ] = method->m_object;

        for ( int i = 0; i < arg_count; i++ )
        {
            new_args[ i + 1 ] = PyTuple_GET_ITEM( args, i );
        }

        if ( kw || method->m_function->m_direct_arg_parser == NULL )
        {
            return method->m_function->m_code(
                method->m_function,
                new_args,
                arg_count + 1,
                kw
            );
        }
        else
        {
            return method->m_function->m_direct_arg_parser(
                method->m_function,
                new_args,
                arg_count + 1
            );
        }
    }
}
コード例 #16
0
const std::string NFDBNet_ClientPlugin::GetPluginName()
{
	return GET_CLASS_NAME(NFDBNet_ClientPlugin);
}