ConstPointer.hx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (C)2005-2019 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. package cpp;
  23. @:coreType @:include("cpp/Pointer.h") @:native("cpp.Pointer") @:semantics(variable)
  24. extern class ConstPointer<T> {
  25. // ptr actually returns the pointer - not strictly a 'T' - for pointers to smart pointers
  26. // Use value or ref to get dereferenced value
  27. var ptr:Star<T>;
  28. var value(get, never):T;
  29. // Typecast to non-const
  30. var raw(get, never):RawPointer<T>;
  31. // const version
  32. var constRaw(get, never):RawConstPointer<T>;
  33. function get_value():Reference<T>;
  34. function get_constRaw():RawConstPointer<T>;
  35. function get_raw():RawPointer<T>;
  36. function lt(inOther:ConstPointer<T>):Bool;
  37. function leq(inOther:ConstPointer<T>):Bool;
  38. function gt(inOther:ConstPointer<T>):Bool;
  39. function geq(inOther:ConstPointer<T>):Bool;
  40. function setRaw<O>(ptr:RawPointer<O>):Void;
  41. static function fromRaw<T>(ptr:RawConstPointer<T>):ConstPointer<T>;
  42. @:native("::cpp::Pointer_obj::fromRaw")
  43. static function fromStar<T>(star:Star<T>):ConstPointer<T>;
  44. static function fromPointer<T>(inNativePointer:Dynamic):ConstPointer<T>;
  45. function reinterpret<Other>():Pointer<Other>;
  46. function rawCast<Other>():RawPointer<Other>;
  47. function at(inIndex:Int):Reference<T>;
  48. function inc():ConstPointer<T>;
  49. function dec():ConstPointer<T>;
  50. function incBy(inT:Int):ConstPointer<T>;
  51. function decBy(inT:Int):ConstPointer<T>;
  52. function add(inT:Int):ConstPointer<T>;
  53. function sub(inT:Int):ConstPointer<T>;
  54. function postIncVal():Reference<T>;
  55. }