Jump to content
  • Advertisement

chasester123

Member
  • Content Count

    22
  • Joined

  • Last visited

Community Reputation

171 Neutral

About chasester123

  • Rank
    Member

Personal Information

  • Interests
    Design
    DevOps
    Programming
  1. chasester123

    Virtual Inheritance

    Not 100% but i do believe this is because you are trying to cast Iplayer as an Ientity type. So you are asking for the function pointer to IPlayer::GetType() and not IEnity::Gettype(); Because this is an inherited class IPlayer doesnt have this function because its owned by IEnity. So when you say typename T and pass IPlayer and try to get the pointer inside of RegisterBaseMember<T> it is Looking for a IPlayer::* or a member of IPlayer, but get type is a member of IEnity::*. How I would handle this is doing Struct IPlayer : IEntity { ... int GetEntity() { IEntity::Gettype(); } } Im probably wrong here Im not 100% sure on how to approach this but this makes sense to me
  2. @Geom library. I have a library already. I was wondering if you want a version of it with it added as a script object in angelscript. @Wrapper I was more asking what exactly would you want in the wrapper. I have macros for globalFunctions globalVaribles, objectMethods, objectProperties, asFuncitonto/C++Template, Operators, etc If you give me some build specs I can make something since im already doing something very simpler. @Generic How useful is generic, is it something that people have to use often. I mostly ask for my person project, I want to know if I should always include a generic form for all of the defined functions? @Inline Definitions Technically there is a way of defining global functions and varibles out side of a function (I assume im using the wrong name for this) using a macro. #define asCOMMAND(ret, name, prefab) static bool __DUMMY__##ret##name = \ addcommand(str( str(#ret) + str(#name) + str(#prefab)), asFUNCTIONPR(ret, name, prefab)); void addcommand(str def, void *(f)(void)); //This would basically store the definition and the string name so that after all of the objects //have been defined by script##name##.h it would run adding all of the underlying globals. int hello(int a) {cout << "hello: " << a;} asCOMMAND(int, hello, (int)); Basically the goal would be to make it easier to define things in angel script by letting you define them inline where the function definition is and then have them automatically added later. chasester
  3. well i found a few improvements when talking to my brother which i will update but i was concerned with: (*new int(max - (i++))) creating a memory leak so im looking into using an auto_pointer to fix this issue. Ill look at the auto wrapper. I haven't looked at much of the add on code, most of it looks very tedious so i was trying to find a more portable solution since i have a lare number of classes I want to add to the library. Also i've not seen a good geom libray written in the addon (like vec, matrix etc) is there one? I feel like every time I look there are more add-ons which i've never seen for some reason (im probably just blind). I appreciate your quick response as always chasester @edit I dont really understand what this header does, maybe seeing a short example would help, but it looks very confusing for what I'm presuming is something very simple. A lot of copy and pasted code with very little changes. Or maybe this is just way over my head.
  4. So this probably has been done, but I'm wondering if there was a better way to do this. I wrote a global templated function that allows you to use it as the pointing function for any class's constructor reference. Looking at the stringD code I saw there are 2 ways to go about doing this: Usinging asIScriptGeneric, and Calling it natively using a typed member object pointer. Below is some code that does both based on the as_max_portiblity preprocessor define that I created (i assume there is one natively in the engine but I didn't see it): asERRORCHECK(r) assert(r < 0) //I have a much more complex error message system, so this is just to cover for that #define as_max_portiblity 0 #if as_max_portiblity template<class C, typename ...Args> void __constructor__(asIScriptGeneric *gen) { int i = 0, max = sizeof ...(Args); new (gen->GetObject()) C(*static_cast<Args *>(gen->GetAddressOfArg(*std::make_unique<int>((max-(++i)))))...); } #else template<class C, typename ...Args> void __constructor__(C *gen, Args... args) { new (gen) C(Args(args)...); } #endif Once you have defined the type of function you want to use then you need to register this inside of a function like this: void registermyobjects(asIScriptEngine *asEngine) { int r; ... //we have an object registered under the name vec2 ... #if as_max_portiblity r = asEngine->RegisterObjectBehaviour("vec2", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(__constructor__<vec2>), asCALL_GENERIC); asERRORCHECK(r); r = asEngine->RegisterObjectBehaviour("vec2", asBEHAVE_CONSTRUCT, "void f(float, float)", asFUNCTION((__constructor__<vec2, float, float>)), asCALL_GENERIC); asERRORCHECK(r); #else r = asEngine->RegisterObjectBehaviour("vec2", asBEHAVE_CONSTRUCT, "void f()", asFUNCTIONPR((__constructor__<vec2>), (vec2 *), void), asCALL_CDECL_OBJFIRST); asERRORCHECK(r); r = asEngine->RegisterObjectBehaviour("vec2", asBEHAVE_CONSTRUCT, "void f(float, float)", asFUNCTIONPR((__constructor__<vec2, float,float>),(vec2 *,float, float), void), asCALL_CDECL_OBJFIRST); asERRORCHECK(r); #endif ... } This should be fairly self explanatory but i have a class vec2 which can take either (void) or (float,float) as its constructor types. So this should in theory be able to take anytype and pass it into the __constructor__() and it will create an object for you. Let me know what you think. Im curious if anyone has done something like this, or if any one sees a potential problem with this code. In theory I could do the same thing for operator types and maybe even factory functions. chasester @edit 1: Made a mistake where the new int(++i) was passing maxargs ... 0 rather than 0 .... maxargs. Fixed by reversing the numbers with a formula (((++i) - maxargs)*-1). @edit 2: Made max - (++i) so that we dont have to multiply by -1. Also replace *new int() with *std::make_unique<int>() so that we dont run into a memory leak.
  5. chasester123

    Inheritance From Internal C++ Classes

    Say:  //c++ class a  { a *def; }; class c : a { int abc; }; //as class b : c {    b()    {      @a;   } } I Tried something like this but kept running into an error where angel script was not properly set up, then it crashed angel script.    What is the proper way to inherit from a c++ class, what flags do I have to set to get it to work correctly?   chasester
  6. chasester123

    Importing all functions of a module

    #include "FILE_NAME"   I think that's what you are looking for. Though you dont have to include it in every file, once included once it is defined in global space (similar to c++). 
  7. chasester123

    Go-inspired features in Angelscript

    Again, this is debatable. I would think that the same kind of argument applies to structs or classes (having to remember which class member corresponds to what).     Overall, it seems to me that neither of you have ever tried go lang, which I recommend you should do. I know you love your C++ but c'mon, there are other languages and technologies out there.       well if you name your structs correctly its not confusing. If you find you are using this alot i imagine you are doing something wrong. Maybe look at finding a better way to write your code so you dont find it is absolutely necessary to have to alway multi return :) I mean its debatable i guess but most languages dont use this, and its been around for a while, so at the very lest people that write coding languages dont like it. Personally I find no use for them, and have never ran into a case where they would have been better to use then an other method.   but whatever its a pointless debate :) chasester
  8. chasester123

    Go-inspired features in Angelscript

    personally Ive always found multiple returns a very limited and trivial feature. Most the time it is hardly useful and can become confusing. Furthermore there are not too many cases where it is nessary and normally its just easier to put the data in a struct (or class) and send it back that way. This is more organized and leads to less bugs down the line (like having to remember what return index belongs to what. If you just wanna send back varible amounts of data, i find that using non-casted arrays are easier, and about as volatile as multiple return types.   This second one is just plain useless to be honest. I dont think that this could ever be of use to anyone, and just makes code way too unreadable. Ppl have a hard enough time naming their variables, functions, classes, etc correctly this would just turn into a nightmare fast, with very very very very little use, other than to confuse everyone so no one has a clue what's going on.   chasester
  9. chasester123

    Adding handles to angel script objects in c++

    lol i didnt know you could do that 0.0 lol ya seems straight forward engough :) thank :)
  10. So this is a fairly simple question though Idk how easy the answer is.    Assume i have a c++ class cClass and an as class asClass: also assume that cClass allows reference handles.   class asClass {    cClass @parent; }   Now the question is how do I assign what @parent is pointing to in c++.   //c++ code void someFunc() {  asIScriptObject *n =   asEngine->CreateUninitializedScriptObject(sometypeinfo) cClass *c = new cClass(); //how do i assign n::parent handle to point to the memory location of c. }   chasester
  11. chasester123

    Working with and Saving CSerializer/CSerializeObject

    thankx I imagine the reason it was erroring is because vector::length was to short and so when i did the f->read(%vector[0], length) it was either erroring out or throwing the data where ever. Thanx for the help.   chasester
  12. chasester123

    Working with and Saving CSerializer/CSerializeObject

    I found the error I didn't realize that reference objects could not be called from creatuninitializedobject. So I've started on a wrap around that creates an object using CSerialCLASSNAME::create() and creates the object from a datahold class object which has been set up in a tree structure, Then once the object is created then I can simply add them into the serializer as objects and pointers.   Just a simple error I wasnt paying attention to the code :) chasester PS: SideNote:: when passing m_mem  (vector<char>) into my file parser, can i just copy it using vector<char> DataHold::mem = m_mem; or do i have to do a data copy like mem_copy(). And visa vera after reading the data, can I just do a f->read(mem[0], length); or is there a better way to do this. IO operations aren't my forte.
  13. Im Gonna start by saying this question is a preview over about 500+ lines of code (including the default code in CSerializer.h and .cpp) So please ask if something doesnt make sense. Struct node { vec o, vec rot; //vector 3 position and rotation repectively. asIScriptObject *ctrl; //script controler aka user code CSerializeObject *savedata; void store() { if (!c) c = asScript->serializer->storenode(this); } }     This is my base object that needs to be added to the angel script code. This object and all of asObjectType list of members, need to saved to the file.   When serializing this object this is how it its done right now. int CSerialnode::nodeID = -1; //changed at init to the id of Node set by the engine int CSerialvec::nodeID = -1; //changed at init to the id of Vec set by the engine CSerializedValue * CSerializer::storenode(node *g) { if (!m_engine)return NULL; if(!g)return NULL; CSerializedValue *c = new CSerializedValue(&m_root, "SERIAL_OBJECT" , "", g, CSerialnode::nodeID); m_root.m_children.push_back(c); return c; } //NOTE CSerialnode and CSerialvec inherients CUserType void CSerialnode::Store(CSerializedValue *val, void *ptr) { node *g = (node *)ptr; vec *o = new vec(g->o); vec *rot = new vec(g->rot); val->m_children.push_back(new CSerializedValue(val, "pos", "", new vec(g->o), CSerialVec::getID())); //store vec o val->m_children.push_back(new CSerializedValue(val, "rot", "", new vec(g->rot), CSerialVec::getID())); // store vec rot val->m_children.push_back(new CSerializedValue(val, "ctrl", "", g->ctrl, g->ctrl->GetTypeId())); //store the controler for this element } void CSerialnode::Restore(CSerializedValue *val, void *ptr) { node *g = (node *)ptr; val->m_children[0]->Restore(&g->o, CSerialVec::getID()); val->m_children[1]->Restore(&g->rot, CSerialVec::getID()); if (val->m_children[2]) val->m_children[2]->Restore(g->ctrl->object, g->ctrl->object->GetTypeId()); } This should allow me to use the Serializer to Store and Restore they Objects using. bool node::restore() { if (!c) return false; //if no c then object wasnt saved, so delete object. c->Restore(this,CSerialnode::getID()); } This kinda works sometimes I feel like there is some kinda error here when passing the pointers around ??   When Writting to file, The code looks as follows. The concept here is Get all the Namespaces Types, and names in the tree. Then store each object using an ID for each of the before (namespaceID, typeID, nameID). Then first store the vector of strings with the data, then list all the objects using IDs to reference the spot in the vector. This code works almost flawlessly. The question is how do i Reinitialize the object. void CSerializer::save(stream *f) { if (!m_engine) SetEngine(asScript->asEngine); //force the engine only using one engine so this should nv call. names.shrink(0); types.shrink(0); namespaces.shrink(0); saveddata.shrink(0); names.put("__ERROR__"); m_root.save(); PUTLILVECTOR(namespaces); PUTLILVECTOR(types); PUTLILVECTOR(names); f->putlil<uint>(saveddata.length()); loopv(saveddata) saveddata[i]->write(f); } void CSerializer::load(stream *f) { if (!m_engine) SetEngine(asScript->asEngine); m_root.ClearChildren(); names.shrink(0); types.shrink(0); namespaces.shrink(0); saveddata.shrink(0); PULLLILVECTOR(namespaces); PULLLILVECTOR(types); PULLLILVECTOR(names); uint size = f->getlil<uint>(); //conoutf("%d", size); loopi(size)saveddata.put(DataHold::read(f)); loopv(saveddata) { DataHold &sd = *saveddata[i]; sd.print(); } m_root.m_typeId = 0; m_root.m_name = "root"; m_root.m_nameSpace = ""; m_root.m_isInit = true; m_root.load(0); //return; loopi(m_root.m_children.size()) { //what do I put here. //can i just put node *n = new node(); m_root[i].restore(*n, Serialnode::getId()); world.addnode(n); } } //this is where I load up the tree. void CSerializedValue::load(uint index) { loopioff( 1, saveddata.length()) { DataHold &sd = *saveddata[i]; CSerializedValue *child; str name = names[VECTOROVERLOADCHECK(names, sd.nameID)]; str tname = types[VECTOROVERLOADCHECK(types, sd.typeID - (asTYPEID_DOUBLE + 1))]; str nameSP = namespaces[VECTOROVERLOADCHECK(namespaces, sd.namespaceID)]; asIObjectType *ot; if (sd.typeID > asTYPEID_DOUBLE) { if (tname == str("__ERROR__")) tname = "void"; ot = asScript->asEngine->GetObjectTypeByName(tname.c_str()); if (!ot) { asScript->recompilemodule(tname.c_str()); asIScriptModule *mod = asScript->asEngine->GetModule(tname.c_str()); if (!mod){ conoutf("ERROR!!! no mod"); return; } ot = mod->GetObjectTypeByName(tname.c_str()); } } else continue; //handle globals here if (ot) { int typeID = ot->GetTypeId(); void * newptr = asScript->asEngine->CreateUninitializedScriptObject(ot); child = new CSerializedValue(this, name, nameSP, newptr, typeID); this->m_children.push_back(child); } else conoutf("ooops"); i = sd.count(i)-1;//jump to next asObject type } } As of right now, it goes between not creating the object to, throwing a nullpointer error when loading the nodes. inside that last section where I actually create the object and add it to the scene.   Any help would be great. Sorrie If it seems a bit of a a mess. Im trying to reduce the amount of code to make it easier to read.   chasester  
  14. chasester123

    BlindMindStudios JIT-Compiler and AS 2.3

    Objectively I have only seen benchmarks by others and some of them are old (like this). I personally haven't tried making an apple to apple comparison as that would involve writing equal functions in several scripting languages. And I don't want to write them in Lua or something similar, because I hate it's syntax (that is the reason why I'm here happily using AS ). But I guess I will try to do some.   So when I did my research on angle script I choice it for the following reasons: The sytax - it looks just like c++ it basically is a c++ redirect which makes it a very nice scripting language The simplicity - backend via the class and function interface is very clean, well written descriptive functions and classes that make sense and are easy to use The documentation - It is very well documented compared to almost every other scripting language out there. Almost every document, class, function etc is not only defined but also there are clear easy to read description. The examples - there are very well through out simple to follow and expand, examples which make integration easy and simple.   Though I'm not discounting your research on the topic but your topic post was written almost 3 years ago, and provides little to no detail about what kinda code he used. From my understanding, path finding is probably not the best bench mark test, manly due to the fact that angel scipt has not back end memory management system. His code probably was fairly inefficient due to his lack of knowledge of the scripting language. I have been looking around for good bench marks and there really arent many, the most recent one http://urho3d.prophpbb.com/topic454.html?sid=2d7499b0a5a00f5aaa2586b5016e7a61#p2506. This is still fairly old, and due to various compatibility modes that angel script has, this may improve or hurt the final results. It would be nice to see a few standard bench mark test examples, in future releases. There seems to be a lot of bad/miss information about the scripting language/engine, because so little people have spent the time to look at it thoroughly.   chasester
  15. chasester123

    Multiple callbacks for one build error?

      Isn't that the IDE's responsibility?    i just figured you where writing an IDE for your game/editor. How you handle call back response is really up to you. Saying you are releasing (what ever) soley as a game then there would be no need for an IDE (unless you really hate trying to figure out whats going on). But if you want to make it modible or you are releasing it as more of a game/engine, then I think a friendly IDE would definitely help with any kind of user made code. But of course its not a "requirement" my any standard.   chasester
  • 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!