Violet CLM

Members
  • Content count

    19
  • Joined

  • Last visited

Community Reputation

215 Neutral

About Violet CLM

  • Rank
    Member
  1. Search module for string?

    The former. As part of building a module, I would like to know whether any part of its source contains a specific string of characters.
  2. Search module for string?

    I would like to find out from within the program whether a given angelscript module contains an arbitrary string, e.g. "foo(123);" or "foo() >= bar()". The asIScriptModule class has methods for finding a few objects by their declarations, but AFAICT only global names. I know the filepath of the source text file for the module, but reopening the file and searching it seems like it would not be an optimal solution, not least because the file might have one or more #include directives and I'd have to reimplement the entire #include system from scratch. Is there any way to get the full (#include-expanded) source of a module?
  3. Crash On Closing Modules With Shared And Funcdef

    Hmm. I think the crash is gone now, but I'm getting other asserts in a complicated set of circumstances... I'll let you know when I figure out what's going on/a minimal test case.
  4. Crash On Closing Modules With Shared And Funcdef

    Yes, discarding: if (ASengine)   while (ASengine->GetModuleCount())     ASengine->GetModuleByIndex(0)->Discard(); They are separate modules, as I said. Multiple calls are made to CScriptBuilder::StartNewModule.   2.31.1.     ETA: I tried running the application in debug mode and got two asserts, I guess during compilation: asASSERT(func->objectType == intfType); at line 2541 of as_builder.cpp, and asASSERT((asUINT)intfFunc->vfTableIdx == j); at line 3002 of the same file.
  5. Given the following file header.as, funcdef void functype(); shared class classname {} and two separate script modules that are both loaded by the application, in this order, #include "header.as" #include "header.as" classname classinstance; my application consistently crashes when the modules are closed. (Pasting the contents of header.as into each module instead of using #include doesn't make any difference, but this felt clearer.) Removing any of the lines prevents the crash. Loading (and therefore probably closing) the modules in the other order prevents the crash.
  6. Just downloaded v2.30.0 for the virtual property compound assignment, and it's mostly great but there does seem to be an issue. Here's a snippet of the registration: ASengine->RegisterObjectType("jjOBJ", sizeof(Omonster), asOBJ_REF | asOBJ_NOCOUNT ); ASengine->RegisterObjectMethod("jjOBJ", "uint16 get_creatorID() const", asFUNCTION(getCreatorID), asCALL_CDECL_OBJFIRST); ASengine->RegisterObjectMethod("jjOBJ", "uint16 set_creatorID(uint16)", asFUNCTION(setCreatorID), asCALL_CDECL_OBJFIRST); ASengine->RegisterGlobalFunction("jjOBJ @get_jjObjects(int)", asFUNCTION(getObject), asCALL_CDECL); Given that, any of these run fine: jjObjects[0].creatorID = jjObjects[0].creatorID + 2; //or jjOBJ@ obj = jjObjects[0]; obj.creatorID = obj.creatorID + 2; //or jjOBJ@ obj = jjObjects[0]; obj.creatorID += 2; But either of these versions produce a Null Pointer Access exception: jjObjects[0].creatorID += 2; //or get_jjObjects(0).creatorID += 2; The problem seems to exist for any function that returns a handle, even ones that aren't registered as get_*; that was just the easiest one to test given my existing registration. If creatorID is registered with RegisterObjectProperty instead, nothing goes wrong.
  7. Difference between x.opEquals(y) and x==y with funcdefs?

    This feels like a related issue, so I kept in the same topic, but I might be wrong. I mentioned opAssign and = working the same way, but that's not always the case. If the function f is inside of a namespace, then svt.opAssign(ns::f) works just fine, but svt = ns::f crashes. Specifically it would seem to crash the executable at some point during the code compilation, since it doesn't matter if the line never even gets called by anything. EDIT: The same is true for opEquals/==.
  8. Difference between x.opEquals(y) and x==y with funcdefs?

    Excellent, thank you!
  9. I have a value class with a registered opEquals method that takes a function, like so: ASengine->RegisterObjectMethod("SOMEVALUETYPE", "bool opEquals(const SOMEFUNCDEF@ &in)", asMETHOD(INTERNALVERSIONOFTHATVALUETYPE,operator==), asCALL_THISCALL);There is likewise an opAssign method. Any of the following work fine in AngelScript, where svt is a variable of type SOMEVALUETYPE and f is a function of type SOMEFUNCDEF: svt = f; svt.opAssign(f); if (svt.opEquals(f)) {}However, if (svt == f) {}does not compile, returning instead: Shouldn't == work the same way as opEquals, like = works the same way as opAssign? It did in v2.26.3 (or maybe .2, not sure), but seems to have changed at some point since then.
  10. For the record, this seems to be working now. Solution:Register all the arbitary numbers ("bar") as an enum, since that's the easiest way to define true constants in AngelScript, as opposed to read-only values.As ever, register a single funcdef for the AngelScript functions ("foo").Create and register a pointer-length value type ("someproperty"). Overload its opAssign and opEquals methods to accept both funcdef instances and enum instances, and also register an implicit value cast from value type to enum. (That last one not really needed, but it means that other functions need only be overloaded twice -- funcdef or enum -- not thrice -- funcdef, enum, or value type. Less bother.)Add checks in a whole lot of application-internal places to determine when and where addRef() and release() need to be called, including the constructor, destructor, and opAssign for the value type.Thanks again for your time, both in helping me out and in the more general development process.
  11. Thanks for all the help so far... I'm trying some things out and will have more to report later. In the meantime, speaking of funcdefs, one of my collaborators is having an issue with namespaces. The following code apparently worked a couple versions ago, but doesn't now: funcdef void simpleFuncDef(); namespace foo { void simpleFunction() { } } void takeSimpleFuncDef(simpleFuncDef@ f) { } void main() { takeSimpleFuncDef(foo::simpleFunction); } //ERR : No matching signatures to 'takeSimpleFuncDef(foo::simpleFunction)' //INFO : Candidates are: //INFO : void takeSimpleFuncDef(simpleFuncDef@)Likewise: funcdef void simpleFuncDef(); namespace foo { void simpleFunction() { } } void main() { simpleFuncDef@ bar = foo::simpleFunction; } //ERR : Can't implicitly convert from '<null handle>' to 'simpleFuncDef@&'.In each case, adding or removing "@" to "foo::simpleFunction" changes nothing. Is this the intended behavior, or was it working before and not now?
  12. Maybe I should back up a bit, and express the issue in terms of what I would like the result to be, rather than in terms of what happens when I try specific things in order to get there. I want the following code to work in AngelScript: void main() { someObject.someProperty = foo; someObject.someProperty = bar; } void foo() { //do stuff }Where "bar" is defined within the application, and is an arbitrary number, not even necessarily a pointer to a location that exists within the application's allotted memory. Maybe 0, maybe 1, maybe 0x87654321. I don't really care what type it has within AngelScript so long as I can send that arbitrary number back into the application again. I think I can make this other style work: void main() { someObject.setProperty(foo); someObject.setProperty(bar); } void foo() { //do stuff }That works because methods, unlike property accessors, may be successfully overloaded. That's not nearly as pretty, though, and it makes retrieving the value (and being able to compare it both to "foo" and to "bar") pretty cumbersome.
  13. I understand that, but earlier you said "Casts involving funcdefs work just like other casts. What exactly is it that you've tried but didn't work." I showed you what I've tried, and you agreed that it doesn't work, but that doesn't get me any closer to knowing what does work. No, the registering works just fine. It's only the passing as an argument that crashes.
  14. But isn't RegisterObjectBehavior the function used to allow casting of a reference type, as shown here? How do I cast a funcdef, if I can't use asBEHAVE_IMPLICIT_REF_CAST, if I can't register a behavior? Nope, ASengine->RegisterFuncdef("void DifferentFunctionPointer()"); ASengine->RegisterGlobalProperty("DifferentFunctionPointer f", (void*)1);still gives a registration error. EDIT: Oh, wait, I needed to add an @. Let's see if I can make this work... EDIT2: Nope, no help. I can register arbitrary numbers for funcdefs to point to, but if I try to pass one of those arbitrary fundefs as an argument to a function, the program crashes. Apparently passing a pointer in AngelScript involves trying to read the data being pointed to.
  15. C++: ASengine->RegisterFuncdef("void jjBEHAVIOR(jjOBJ@)"); ASengine->RegisterFuncdef("void DifferentFunctionPointer()"); ASengine->RegisterObjectBehaviour("jjBEHAVIOR", asBEHAVE_IMPLICIT_REF_CAST, "DifferentFunctionPointer@ a()", asFUNCTION(someConversionFunction), asCALL_CDECL_OBJLAST); ASengine->RegisterGlobalFunction("void someFunctionTakingAFunctionPointer(DifferentFunctionPointer@)", asFUNCTION(someFunction), asCALL_CDECL); ASengine->RegisterObjectType("MiscRefObject", 0, asOBJ_REF | asOBJ_NOCOUNT ); ASengine->RegisterObjectBehaviour("jjBEHAVIOR", asBEHAVE_IMPLICIT_REF_CAST, "MiscRefObject@ b()", asFUNCTION(someConversionFunction), asCALL_CDECL_OBJLAST); ASengine->RegisterGlobalFunction("void someFunctionTakingAnObject(MiscRefObject@)", asFUNCTION(someFunction), asCALL_CDECL); ASengine->RegisterObjectBehaviour("jjBEHAVIOR", asBEHAVE_IMPLICIT_VALUE_CAST, "uint d()", asFUNCTION(someConversionFunction), asCALL_CDECL_OBJLAST); ASengine->RegisterGlobalFunction("void someFunctionTakingAUint(uint)", asFUNCTION(someFunction), asCALL_CDECL);AngelScript: void TriggerableBlock(jjOBJ@ obj) { //do stuff } //... someFunctionTakingAFunctionPointer(TriggerableBlock); someFunctionTakingAnObject(TriggerableBlock); someFunctionTakingAUint(TriggerableBlock);Each gives an error akin to No matching signatures to 'someFunctionTakingAFunctionPointer(::TriggerableBlock)'. Typing "@TriggerableBlock" instead of "TriggerableBlock" gives the same results. If I don't use _IMPLICIT_ casts: someFunctionTakingAFunctionPointer(cast<DifferentFunctionPointer>(TriggerableBlock)); someFunctionTakingAnObject(cast<MiscRefObject>(TriggerableBlock)); someFunctionTakingAUint(cast<uint>(TriggerableBlock));The first two give No matching signatures to 'someFunctionTakingAFunctionPointer(<unrecognized token>)' and No matching signatures to 'someFunctionTakingAnObject(<unrecognized token>)'. The last gives Illegal target type for reference cast. Also,ASengine->RegisterGlobalProperty("DifferentFunctionPointer f", 0);just gives me a registration error.