Jump to content

  • Log In with Google      Sign In   
  • Create Account

Andreas Jonsson

Member Since 26 Mar 2000
Offline Last Active Today, 11:21 AM

#5303330 Passing "this" As Argument ?&in

Posted by on 31 July 2016 - 09:46 AM

The weakref type currently doesn't have a copy constructor or assignment operator. That's why it doesn't allow you to pass this type by value. I'll have this implemented.

 

I've implemented this in revision 2340.




#5303249 Passing "this" As Argument ?&in

Posted by on 30 July 2016 - 05:04 PM

1. yes. h will hold a reference to foo, and thus increase the ref count. You can inspect the value of the ref count by calling AddRef() and then Release(). Both methods return the refcount.

 

2. @h.method() would mean "call method() on the object referred to by h, and then take the address of the returned type". I should probably add a warning, if the @ symbol is used in cases like this.

 

3. If the left hand expression has the @, then the compiler already knows that the right hand expression also must be operating on the address, so it implicitly adds the @ if it is not there.

 

4. Same thing as 2

 

5. Think of the @ operator as "work on the address of the object". When not using the @ operator you will be working with the actual object, not it's address. That's why when calling my_func(h) makes a copy of the object to pass into the function (since the argument is &in), but my_func(@h) passes in the address of the object.

 

You can also think of the @ symbol as being closer to C++ & symbol, except a variable declared as & cannot be reassigned after initialization.




#5302310 Possible Bug In Asrun Example

Posted by on 24 July 2016 - 10:19 AM

I've fixed this in revision 2336




#5302207 Delayed Calls

Posted by on 23 July 2016 - 01:45 PM

Yes, it is possible and support for variadics is already on my to-do list, but currently not prioritized.




#5301089 Clang Asgettypetraits

Posted by on 17 July 2016 - 10:25 AM

Fixed in revision 2335




#5301082 Clang Asgettypetraits

Posted by on 17 July 2016 - 09:59 AM

Thanks. I'll add defined(__clang__).




#5298148 AngelScript 2.31.1 is out

Posted by on 26 June 2016 - 03:53 PM

Despite it being 4 months since the last release, this is not a big release. This release contains mostly bug fixes and a few minor enhancements.

 

I would have liked to include more, but time to work on AngelScript has been very short the last months. Rather than prolonging the release further until I had the time to implement something bigger, I decided it was time to release what I had so that everyone can take advantage of the bug fixes.

 

Regards,

Andreas




#5298030 Problem with a function of C++ object which returns a delegate to the AngelSc...

Posted by on 25 June 2016 - 03:36 PM

Is this with version 2.31.0? 

 

Have you tried the latest WIP version? Several bugs related to function pointers crept into version 2.31.0, but all of them have been fixed in the WIP version already (including a bug that prevented returning function pointers from registered functions)




#5292546 The compiler crashes

Posted by on 19 May 2016 - 06:20 PM

As I suspected. This problem had already been fixed in the latest WIP version.

 

 

Thanks for the compliments on the library. Let me know if you encounter any other problems, or have any suggestions for how to improve the library further.

 

Regards,

Andreas




#5290891 Various unexpected behaviors of AngelScript 2.31.0

Posted by on 09 May 2016 - 04:29 PM

Thanks for letting me know. I'll look into it.




#5290677 BmFont does not includes invalid char glyph in my own font

Posted by on 08 May 2016 - 11:34 AM

The following is used to determine the glyph index for the invalid char glyph:

// Get the default character instead
TEXTMETRICW tm;
GetTextMetricsW(dc, &tm);
WORD glyph;
fGetGlyphIndicesW(dc, &tm.tmDefaultChar, 1, &glyph, 0);
idx = glyph;

There appears to be a bug in BMFont when not rendering the glyphs from the true type outline though. I'll need to investigate and fix this.




#5284410 Refcount mismatch when discarding module.

Posted by on 30 March 2016 - 08:57 PM

I've fixed the bug in revision 2309. 

 

If you don't want to upgrade to the latest revision from the SVN, you ought to be able to apply this fix locally to version 2.30.2.

 

https://sourceforge.net/p/angelscript/code/2309/tree//trunk/sdk/angelscript/source/as_module.cpp?diff=2274

 

Regards,

Andreas




#5284265 AngelScript and Fastdelegates

Posted by on 30 March 2016 - 08:45 AM

True, an arbitrary method pointer can have different sizes. But in your case the method pointer to the FastDelegate's operator() method will always be of the same size regardless of the arguments (on MSVC it will have the size of a simple pointer), but in your case you're probably best to typedef a simple class method as it will be more portable.

 

 

// Declare a simple dummy class so the compiler can determine what a method pointer would look like,

// i.e. it can see that the method pointer won't need to keep track of multiple or virtual inheritances

class CSimpleDummy {};

typedef void (CSimpleDummy::*SIMPLEMETHOD_t)();
 
// Take the address of the FastDelegate's class method like this:
SIMPLEMETHOD_t methodAddr = reinterpret_cast<SIMPLEMETHOD_t >(&ScriptComponentMethodString::operator());
 
 

The methodAddr can then be passed from the exe to the dll just like any other primitive type. AngelScript will take care of interpreting the method pointer and setting up the arguments for the call dynamically based on what you tell it in the function declaration string when registering the method with the engine.




#5283625 Various unexpected behaviors of AngelScript 2.31.0

Posted by on 26 March 2016 - 04:36 PM

I've fixed all the bugs reported here in revision 2308.

 

Thanks,

Andreas




#5282692 Various unexpected behaviors of AngelScript 2.31.0

Posted by on 22 March 2016 - 11:49 AM

All, except the last are valid bugs and I'll look into them, and have them fixed a.s.a.p.

 

The last one is as you suspect a special case, and while it may look odd, it is specifically designed to work so that this type of expression can be used in code where you don't know at the time of writing the actual type of the argument given to the function. Consider for example macros, templates, or mixins, where you write the code once and then reuse it in different situations.

 

I also have a case in the console sample that takes advantage of this. Here I register various overloads of a special function called _grab that is used to catch the value of the expression written on the console input line and print it on the screen. When the expression doesn't have any value (i.e. void) then the overload _grab() is used. The statement written to the console input is then compiled and executed by the application like this:

void ExecString(asIScriptEngine *engine, string &arg)
{
  string script;
 
  // Wrap the expression in with a call to _grab, which allow us to print the resulting value
  script = "_grab(" + arg + ")";
 
  int r = ExecuteString(engine, script.c_str(), engine->GetModule("console"));
  if( r < 0 )
    cout << "Invalid script statement. " << endl;
  else if( r == asEXECUTION_EXCEPTION )
    cout << "A script exception was raised." << endl;
}

If this is causing a problem for you I could add an engine property to allow you to turn off this behaviour in your application.






PARTNERS