1*8975f5c5SAndroid Build Coastguard Worker// 2*8975f5c5SAndroid Build Coastguard Worker// Copyright 2014 The ANGLE Project Authors. All rights reserved. 3*8975f5c5SAndroid Build Coastguard Worker// Use of this source code is governed by a BSD-style license that can be 4*8975f5c5SAndroid Build Coastguard Worker// found in the LICENSE file. 5*8975f5c5SAndroid Build Coastguard Worker 6*8975f5c5SAndroid Build Coastguard Worker// Error.inc: Inline definitions of egl::Error and gl::Error classes which encapsulate API errors 7*8975f5c5SAndroid Build Coastguard Worker// and optional error messages. 8*8975f5c5SAndroid Build Coastguard Worker 9*8975f5c5SAndroid Build Coastguard Worker#include "common/angleutils.h" 10*8975f5c5SAndroid Build Coastguard Worker 11*8975f5c5SAndroid Build Coastguard Worker#include <cstdarg> 12*8975f5c5SAndroid Build Coastguard Worker 13*8975f5c5SAndroid Build Coastguard Workernamespace egl 14*8975f5c5SAndroid Build Coastguard Worker{ 15*8975f5c5SAndroid Build Coastguard Worker 16*8975f5c5SAndroid Build Coastguard WorkerError::Error(EGLint errorCode) 17*8975f5c5SAndroid Build Coastguard Worker : mCode(errorCode), 18*8975f5c5SAndroid Build Coastguard Worker mID(0) 19*8975f5c5SAndroid Build Coastguard Worker{ 20*8975f5c5SAndroid Build Coastguard Worker} 21*8975f5c5SAndroid Build Coastguard Worker 22*8975f5c5SAndroid Build Coastguard WorkerError::Error(const Error &other) 23*8975f5c5SAndroid Build Coastguard Worker : mCode(other.mCode), 24*8975f5c5SAndroid Build Coastguard Worker mID(other.mID) 25*8975f5c5SAndroid Build Coastguard Worker{ 26*8975f5c5SAndroid Build Coastguard Worker if (other.mMessage) 27*8975f5c5SAndroid Build Coastguard Worker { 28*8975f5c5SAndroid Build Coastguard Worker createMessageString(); 29*8975f5c5SAndroid Build Coastguard Worker *mMessage = *(other.mMessage); 30*8975f5c5SAndroid Build Coastguard Worker } 31*8975f5c5SAndroid Build Coastguard Worker} 32*8975f5c5SAndroid Build Coastguard Worker 33*8975f5c5SAndroid Build Coastguard WorkerError::Error(Error &&other) 34*8975f5c5SAndroid Build Coastguard Worker : mCode(other.mCode), 35*8975f5c5SAndroid Build Coastguard Worker mID(other.mID), 36*8975f5c5SAndroid Build Coastguard Worker mMessage(std::move(other.mMessage)) 37*8975f5c5SAndroid Build Coastguard Worker{ 38*8975f5c5SAndroid Build Coastguard Worker} 39*8975f5c5SAndroid Build Coastguard Worker 40*8975f5c5SAndroid Build Coastguard WorkerError &Error::operator=(const Error &other) 41*8975f5c5SAndroid Build Coastguard Worker{ 42*8975f5c5SAndroid Build Coastguard Worker mCode = other.mCode; 43*8975f5c5SAndroid Build Coastguard Worker mID = other.mID; 44*8975f5c5SAndroid Build Coastguard Worker 45*8975f5c5SAndroid Build Coastguard Worker if (other.mMessage) 46*8975f5c5SAndroid Build Coastguard Worker { 47*8975f5c5SAndroid Build Coastguard Worker createMessageString(); 48*8975f5c5SAndroid Build Coastguard Worker *mMessage = *(other.mMessage); 49*8975f5c5SAndroid Build Coastguard Worker } 50*8975f5c5SAndroid Build Coastguard Worker else 51*8975f5c5SAndroid Build Coastguard Worker { 52*8975f5c5SAndroid Build Coastguard Worker mMessage.reset(); 53*8975f5c5SAndroid Build Coastguard Worker } 54*8975f5c5SAndroid Build Coastguard Worker 55*8975f5c5SAndroid Build Coastguard Worker return *this; 56*8975f5c5SAndroid Build Coastguard Worker} 57*8975f5c5SAndroid Build Coastguard Worker 58*8975f5c5SAndroid Build Coastguard WorkerError &Error::operator=(Error &&other) 59*8975f5c5SAndroid Build Coastguard Worker{ 60*8975f5c5SAndroid Build Coastguard Worker if (this != &other) 61*8975f5c5SAndroid Build Coastguard Worker { 62*8975f5c5SAndroid Build Coastguard Worker mCode = other.mCode; 63*8975f5c5SAndroid Build Coastguard Worker mID = other.mID; 64*8975f5c5SAndroid Build Coastguard Worker mMessage = std::move(other.mMessage); 65*8975f5c5SAndroid Build Coastguard Worker } 66*8975f5c5SAndroid Build Coastguard Worker 67*8975f5c5SAndroid Build Coastguard Worker return *this; 68*8975f5c5SAndroid Build Coastguard Worker} 69*8975f5c5SAndroid Build Coastguard Worker 70*8975f5c5SAndroid Build Coastguard WorkerEGLint Error::getCode() const 71*8975f5c5SAndroid Build Coastguard Worker{ 72*8975f5c5SAndroid Build Coastguard Worker return mCode; 73*8975f5c5SAndroid Build Coastguard Worker} 74*8975f5c5SAndroid Build Coastguard Worker 75*8975f5c5SAndroid Build Coastguard WorkerEGLint Error::getID() const 76*8975f5c5SAndroid Build Coastguard Worker{ 77*8975f5c5SAndroid Build Coastguard Worker return mID; 78*8975f5c5SAndroid Build Coastguard Worker} 79*8975f5c5SAndroid Build Coastguard Worker 80*8975f5c5SAndroid Build Coastguard Workerbool Error::isError() const 81*8975f5c5SAndroid Build Coastguard Worker{ 82*8975f5c5SAndroid Build Coastguard Worker return (mCode != EGL_SUCCESS); 83*8975f5c5SAndroid Build Coastguard Worker} 84*8975f5c5SAndroid Build Coastguard Worker 85*8975f5c5SAndroid Build Coastguard Workervoid Error::setCode(EGLint code) 86*8975f5c5SAndroid Build Coastguard Worker{ 87*8975f5c5SAndroid Build Coastguard Worker mCode = code; 88*8975f5c5SAndroid Build Coastguard Worker} 89*8975f5c5SAndroid Build Coastguard Worker 90*8975f5c5SAndroid Build Coastguard Worker// Static 91*8975f5c5SAndroid Build Coastguard WorkerError Error::NoError() 92*8975f5c5SAndroid Build Coastguard Worker{ 93*8975f5c5SAndroid Build Coastguard Worker return Error(EGL_SUCCESS); 94*8975f5c5SAndroid Build Coastguard Worker} 95*8975f5c5SAndroid Build Coastguard Worker 96*8975f5c5SAndroid Build Coastguard Worker} 97