Jump to content

TurboMagic

Members
  • Content Count

    46
  • Joined

  • Last visited

Community Reputation

11 Good

Recent Profile Visitors

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

  1. Small status update: it looks I have fixed all non object related issues. At least the unit tests for those do run and the same unit tests as implemented for unmanaged types have ben implemented for strings as well and they do run. What's left now is the OwnsObjects semantics and tests for interfaces and regular classes. That's the state of the development branch.
  2. I fixed the Add(Items:TRingbufferArray) now, it might need further test coverage for managed types, but that at least fixed some of the failed string test cases now. Peek no longer crashes and while working on that I had see that Peek had already a value in Result at the beginning of the method. Trying to set that to Default(T) there crashed immediately. So fixing add was the right thing. One thing which still puzzles me and maybe is not even possible: I can have such a generic ringbuffer class which works for non managed types and for reference counted types at the same time. But I don't seem to be able to make it work with objects and OwnsObject semantics, as I cannot call free. I can only call free if I introduce a class constraint. Is this assumption correct and my initial attempt with a class for objects inheriting from the first one is the right one? I already tried to find out how TObjectList<T> from Generics.Collections does it, but I failed to find the free of the items in it...
  3. TurboMagic

    Loading shared objects on Android

    Yes, I resolved it by upgrading the student to 10.3.3 and then using the permission request solution provided there. It works now and if you check the github repo you'll see it's in there as well 😉 So if you need to create a video on Android you can use that solution right away 😉 The only thing missing there is an iOS implementation as I don't have any iPhone and Mac.
  4. Access violation, but I don't know why. Ok, I started to write some further unit tests now as a start to fix the issues this implementation has in order to learn some things. I copied the integer unit tests which run fine and reworked those into string ones. so <T> is string now. One of the tests calls this method: function TRingbuffer<T>.Peek(Index: UInt32): T; var reminder : UInt32; begin if (Index < Count) then begin // Puffer läuft derzeit nicht über seine obere Grenze hinaus if ((FStart+Index) < Size) then result := FItems[FStart+Index] else begin // um wieviel geht es über die obere Grenze hinaus? reminder := (FStart+Index)-Size; result := FItems[reminder]; end; end else raise EArgumentOutOfRangeException.Create('Invalid Index: '+Index.ToString+ ' Max. Index: '+Count.ToString); end; FItems at that point contains 5 items, FStart is 1 and Index is 1 as well. It crashes with EInvalidPointer at this line: result := FItems[FStart+Index] When debugging the asm I see some call to freemem. I would have expected that Peek would simply return a string with the contents of FItems[FStart+Index] and that it would increase the reference counter of the string stored in FItems[FStart+Index]. This Peek method is called in a loop over the complete ringbuffer to check if its contents is the expected one. For Index = 0 it doesn't crash. What is wrong on my assumption? And the other question would be: should peek increase reference counter of reference counted types (string, interface...) or return a copy which is not reference counted and thus completely detached from the buffer inside the ring buffer class? And if "detached" should be preferred, how to do the copying properly?
  5. TurboMagic

    Loading shared objects on Android

    By the way: the whole thing is now available here: https://github.com/rmesch/Bitmaps2Video Android 64 bit support for the sample provided should be available soon, I need to commit it and create a pull request. Which I'll do in a minute.
  6. TurboMagic

    Byte and Integer

    I guess it's rather a missing overflow check in the server software for the vote counter 😉 But I guess this Jira software is not written in Delphi (oh, if it were overflow checking would be available and this issue would have been caught during testing...) Of course I voted for this as well.
  7. If your Delphi version is new enough to support generics: Create a TDictionary where the key is the number (ID) of the question and the data is the number of points of the answer selected. Store the ID of the question in the tag of the tab the question is on (assuming one tab holds one question, if not put each question in some container which has a tag, it doesn't matter if that container is visible or not). Store the number of points associated with an anwer to the question in the tag of the checkbox or radio button for the answer. If somebody selects an answer look in the list if there is already some entry with hat question ID. If yes, remove it and add it again with the new data or overwrite the data. When the questionaire is finished iterate through the dictionary and count the points. uses Generics.Collections; type // first one is the key = question ID, last one the data asociated with the key in your case the points. TAnswerDict = Dictionary<integer, integer>; var Answers:TAnswerDict; Pair: TPair; Points: Integer; begin Answers := TAnswerDict.Create; try Answers.Add(1,3); Answers.Add(2,1); Points := 0; for Pair in Answers do inc(Points, Pair.Value); finally Answers.Free; end; end. The code has not been tested but it should be a starting point for you, if still relevant.
  8. Ok, besides accepting Uwe's pull request I did some changes to the Peek method in order to make it more compatible with managed types. Feel free to look at it and critisise where necessary, I admit that I didn't test it yet (need to create unit tests) but it's getting late enough already. I can only learn from it. And if somebody wants to contribute: feel free. As far as I understood Stefan, one could get rid of the 2nd class implemented for managed types altogether by using IsManaged and calling the appropriate code to release the items where necessary.
  9. Yes, unit tests for managed types would still have to be created. And yes one would have to do some for strings and interfaces as well as tey're of course managed as well. I contributed this to the public because it will not help the community if one always consumes only without giving. That also means, if there's interest in this library others should contribute fixes etc. as well. My main open source commitment currently is DEC (Delphi Encryption Compendium) and that's enough work.
  10. Thanks! That could be fixed at the place where items get taken out of the list. I guess one would have to make a distinction of cases via IsManagedType(T) so one can keep using Move for non manages types and assignment operator for managed ones. Would that be correct?
  11. Ok, I think I see what you're after. In case of the peek one would have to use the assignment operator then (if the type is a managed one) in order to increase the reference counter. Am I right? But how to find out whether the type is managed?
  12. Why would those have to be cleared? One shoukdn't be able to read those out and I don't remember but if the buffer has to free any instances contained in it when the buffer is freed it will only free the instances still in the buffer.
  13. Since I didn't hear from him with a ull request or any other "delivery" yet I guess he got stuck translating the comments...
  14. Ok, I see the FAQ pages but in the wiki documentation for the various components the SSL ones are usually read = nonexisting links. My earlier question was what we can do to help generate the Wiki sceleton as automatically as possible. About the help you started to create: is this CHM based and is the "source" available for contribution somewhere?
×