Jump to content
  • Advertisement

Jason Goepel

Member
  • Content Count

    119
  • Joined

  • Last visited

Community Reputation

797 Good

About Jason Goepel

  • Rank
    Member

Personal Information

  • Role
    Programmer
  • Interests
    Programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Jason Goepel

    Try/Catch Support

    I noticed this in the 2.33.0 WIP page: "Added support for try/catch statements" I'm sure you will elaborate the feature in the documentation, but I was curious if this "try/catch" behavior was going to include "throw" statements? If so, would the "catch" statement be able to catch a specific kind of exception? Could there be some sort of variable or function accessible from the "catch" statement that could contain information about the exception? Thank you
  2. Jason Goepel

    Template Factory Return Type Bug

    My application is experiencing a crash in a template object's factory, because the asITypeInfo pointer being passed to the factory does not have a valid subtype. I've tried to track down the cause of this bug, and I suspect that the reference counting of template function return types may be incorrect. When a module contains a template instantiation, function objects are added to the script engine. Building a second module with an identical script will reuse those function objects. After discarding the first module though, the return types of those function objects are no longer valid. Below I have constructed a simple example which crashes due to a null engine pointer in the return type of a factory function. class MyTmpl { public: MyTmpl(asITypeInfo *t) { refCount = 1; type = t; OutputDebugStringA(asGetActiveContext()->GetFunction(0)->GetDeclaration()); type->AddRef(); } ~MyTmpl() { if( type ) type->Release(); } void AddRef() { refCount++; } void Release() { if( --refCount == 0 ) delete this; } asITypeInfo *type; int refCount; }; MyTmpl *MyTmpl_factory(asITypeInfo *type) { return new MyTmpl(type); } asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); engine->RegisterObjectType("MyTmpl<class T>", 0, asOBJ_REF | asOBJ_TEMPLATE); engine->RegisterObjectBehaviour("MyTmpl<T>", asBEHAVE_FACTORY, "MyTmpl<T> @f(int&in)", asFUNCTIONPR(MyTmpl_factory, (asITypeInfo*), MyTmpl*), asCALL_CDECL); engine->RegisterObjectBehaviour("MyTmpl<T>", asBEHAVE_ADDREF, "void f()", asMETHOD(MyTmpl, AddRef), asCALL_THISCALL); engine->RegisterObjectBehaviour("MyTmpl<T>", asBEHAVE_RELEASE, "void f()", asMETHOD(MyTmpl, Release), asCALL_THISCALL); asIScriptModule *mod1 = engine->GetModule("m1", asGM_ALWAYS_CREATE); asIScriptModule *mod2 = engine->GetModule("m2", asGM_ALWAYS_CREATE); const char* script_text = "void main() { MyTmpl<int> s; }"; mod1->AddScriptSection("test1", script_text); mod1->Build(); mod2->AddScriptSection("test2", script_text); mod2->Build(); mod1->Discard(); asIScriptContext *ctx = engine->CreateContext(); asIScriptFunction *func = mod2->GetFunctionByDecl("void main()"); ctx->Prepare(func); ctx->Execute(); ctx->Release(); engine->Release();
  3. Jason Goepel

    Bitwise Operator

    Thanks for implementing this. I do have one question. I notice you are testing the left-hand and right-hand contexts for floating-point types. Since the bit-wise comparison only applies to integral types, why not test more explicitly for those (like below)? // Also do not permit implicit convertion to integer in this case as the user may think // the result is a bitwise operation on the original type but it's not if (!lctx->type.dataType.IsIntegerType() && !lctx->type.dataType.IsUnsignedType()) { asCString str; str.Format(TXT_ILLEGAL_OPERATION_ON_s, lctx->type.dataType.Format(outFunc->nameSpace).AddressOf()); Error(str, node); // Set an integer value and allow the compiler to continue ctx->type.SetConstantDW(asCDataType::CreatePrimitive(ttInt, true), 0); return; } if (!rctx->type.dataType.IsIntegerType() && !rctx->type.dataType.IsUnsignedType()) { asCString str; str.Format(TXT_ILLEGAL_OPERATION_ON_s, rctx->type.dataType.Format(outFunc->nameSpace).AddressOf()); Error(str, node); // Set an integer value and allow the compiler to continue ctx->type.SetConstantDW(asCDataType::CreatePrimitive(ttInt, true), 0); return; }
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!