Jump to content
  • Advertisement

Chisser98

Member
  • Content count

    29
  • Joined

  • Last visited

Community Reputation

136 Neutral

About Chisser98

  • Rank
    Member

Personal Information

  • Interests
    Programming
  1. Chisser98

    implementing partial templates

    Oh awesome, I didn't know that, thanks WitchLord!
  2. Chisser98

    implementing partial templates

    hmm..what I was trying to get at is to allow the use of the angle brackets when defining a type in Angelscript. so I could register the type `vector<int>` Which would be implemented with a `std::vector<int> `. so in angel script I could write something like: vector<int> myInts; myInts.push_back(1); and it would work, but if I used: vector<float> myFloats; myFloats.push_back(1.0f); it would fail to compile since the type `vector<float>` is not a defined type. does that make sense?
  3. Chisser98

    implementing partial templates

    Hi, I'm curious if anyone else would think that the use of a 'partial template' system in Angelscript would be useful. Specifically, if I want to bind a std::vector, I need to give it a unique name for each type (i.e. vectorInt, vectorFloat, etc). What if Angelscript could allow the use of the angle bracket syntax to name a type (i.e. Bind `std::vector<int>` to `vector<int>`). A user would not be able to instantiate a `vector<float>` unless this type was registered. does anyone think this might be useful? I haven't looked at the code yet, so I'm not sure how complicated this might be.
  4. Chisser98

    passing class/function to asMETHOD

    Ah, right.  Thanks saejox, AngelBinder was a big help.   Well, I guess it's pretty clear by now that I have no idea what I'm doing:     So, after more researching, and asking around a little on stackoverflow, I have something compiling.   However, now I seem to be unable to create a asSMethodPtr object...   I define the following struct:     struct S {     int f()     {         return 5;     }     int x = 10; };     and use it thusly:         asSMethodPtr pt = asSMethodPtr<sizeof( void (S::*)() )>::Convert( AS_METHOD_AMBIGUITY_CAST( int (S::*)()) (&S::f) );     However, I get the following compile time exception:     template_tests.cpp: In function ‘int main()’: template_tests.cpp:64:15: error: missing template arguments before ‘pt’ template_tests.cpp:64:15: error: expected ‘;’ before ‘pt’     Any idea why in the world I get that?     If I try to add an integer in there as a template, like so:   asSMethodPtr<16> pt = asSMethodPtr<sizeof( void (S::*)() )>::Convert( AS_METHOD_AMBIGUITY_CAST( int (S::*)()) (&S::f) );       I get this error instead: template_tests.cpp: In function ‘int main()’: template_tests.cpp:66:120: error: conversion from ‘asSFuncPtr’ to non-scalar type ‘asSMethodPtr<16>’ requested
  5. Chisser98

    passing class/function to asMETHOD

    Ok, I'm trying to actually figure out how to do it...How do you create a asSMethodPtr struct object without the Macro...?   I've got this:   auto methodPtr = asSMethodPtr<sizeof(void (classObject.pointer)())>::Convert((void (classObject.pointer)())(classObject.addRefMethodPointer));     (Where 'classObject' is a struct of type 'Class' (defined in my first post))   But it doesn't compile, I get:      src/common/as_wrapper/AngelScript.cpp:98:66: error: void value not ignored as it ought to besrc/common/as_wrapper/AngelScript.cpp:98:68: error: template argument 1 is invalid src/common/as_wrapper/AngelScript.cpp:98:107: error: void value not ignored as it ought to be     Any ideas?  I've afraid this asSMethodPtr struct is pushing the limits of my C++ abilities...
  6. Chisser98

    passing class/function to asMETHOD

    Ahh that makes sense.  I'll give wrapping asSFuncPtr a go.   Thanks SiCrane.
  7. Chisser98

    passing class/function to asMETHOD

    hey all   I'm writing a thin wrapper for Angelscript for my game.   I'm a little unsure how to actually 'wrap' the asMETHOD macro.   I've got something like this so far:       void AngelScript::registerClass(Class classObject, std::vector<Method> methods) { registerObjectType(classObject.name.c_str(), 0, asOBJ_REF); registerObjectBehaviour(classObject.name.c_str(), asBEHAVE_FACTORY, classObject.factorySignature.c_str(), asFUNCTION(classObject.factoryPointer), asCALL_CDECL); registerObjectBehaviour(classObject.name.c_str(), asBEHAVE_ADDREF, "void f()", asMETHOD(classObject.pointer, classObject.addRefMethodPointer), asCALL_THISCALL); registerObjectBehaviour(classObject.name.c_str(), asBEHAVE_RELEASE, "void f()", asMETHOD(classObject.pointer, classObject.releaseRefMethodPointer), asCALL_THISCALL); for ( Method m : methods) { registerMethod(classObject, m); } }       where Class and Method are defined as:      struct Class { std::string name; std::string factorySignature; void* pointer; void* factoryPointer; void* addRefMethodPointer; void* releaseRefMethodPointer; }; struct Method { std::string name; std::string signature; void* pointer; };         Unfortuantely, my compiler is giving me an error like this:    src/common/as_wrapper/AngelScript.cpp: In member function ‘void as_wrapper::AngelScript::registerClass(as_wrapper::Class, std::vector<as_wrapper::Method>)’: src/common/as_wrapper/AngelScript.cpp:100:160: error: template argument 1 is invalid src/common/as_wrapper/AngelScript.cpp:101:165: error: template argument 1 is invalid     Where line 100 and 101 are these two lines:     ... registerObjectBehaviour(classObject.name.c_str(), asBEHAVE_ADDREF, "void f()", asMETHOD(classObject.pointer, classObject.addRefMethodPointer), asCALL_THISCALL); registerObjectBehaviour(classObject.name.c_str(), asBEHAVE_RELEASE, "void f()", asMETHOD(classObject.pointer, classObject.releaseRefMethodPointer), asCALL_THISCALL); ...       I'm not sure how I would go about passing (whatever it is) I need to pass to the asMETHOD to get this sucker compiled.   Anyone have any ideas?
  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!