GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — livecode/libscript/src/module-bitwise.cpp at develop · livecode/livecode
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
Expand file tree/ Copy pathmodule-bitwise.cppMore file actions 96 lines (75 loc) · 2.71 KB / Copy pathmodule-bitwise.cppFile metadata and controls96 lines (75 loc) · 2.71 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 /* Copyright (C) 2003-2015 LiveCode Ltd. This file is part of LiveCode. LiveCode is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License v3 as published by the Free Software Foundation. LiveCode is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with LiveCode. If not see <http://www.gnu.org/licenses/>. */ #include <foundation.h> extern "C" MC_DLLEXPORT_DEF void MCBitwiseEvalBitwiseAnd(integer_t p_left, integer_t p_right, integer_t& r_output) { r_output = p_left & p_right; } extern "C" MC_DLLEXPORT_DEF void MCBitwiseEvalBitwiseOr(integer_t p_left, integer_t p_right, integer_t& r_output) { r_output = p_left | p_right; } extern "C" MC_DLLEXPORT_DEF void MCBitwiseEvalBitwiseXor(integer_t p_left, integer_t p_right, integer_t& r_output) { r_output = p_left ^ p_right; } extern "C" MC_DLLEXPORT_DEF void MCBitwiseEvalBitwiseNot(integer_t p_operand, integer_t& r_output) { r_output = ~p_operand; } /* Compute the maximum shift possible in C for a given operand. */ template <typename T> static inline void MCBitwiseEvalBitwiseShiftCount (T p_operand, uinteger_t & p_shift) { /* Maximum shift count for which the C operator is defined */ uinteger_t t_max_shift = (sizeof(T) << 3) - 1; p_shift = MCMin (p_shift, t_max_shift); } extern "C" MC_DLLEXPORT_DEF void MCBitwiseEvalBitwiseShiftRight (integer_t p_operand, uinteger_t p_shift, integer_t & r_output) { MCBitwiseEvalBitwiseShiftCount (p_operand, p_shift); r_output = p_operand >> p_shift; } extern "C" MC_DLLEXPORT_DEF void MCBitwiseEvalBitwiseShiftLeft (integer_t p_operand, uinteger_t p_shift, integer_t& r_output) { MCBitwiseEvalBitwiseShiftCount (p_operand, p_shift); integer_t t_shifted = p_operand << p_shift; /* Overflow check */ if (p_operand != t_shifted >> p_shift) { MCErrorCreateAndThrow (kMCGenericErrorTypeInfo, "reason", MCSTR("overflow in bitwise operation"), nil); return; } r_output = t_shifted; } //////////////////////////////////////////////////////////////////////////////////////////////////// extern "C" bool com_livecode_bitwise_Initialize(void) { return true; } extern "C" void com_livecode_bitwise_Finalize(void) { } //////////////////////////////////////////////////////////////////////////////////////////////////// #ifdef _TEST void MCBitwiseRunTests() { } #endif |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |