blob: 818378ca422f075c583ac270b510c9018f0410e9 [file] [log] [blame]
{{/*
* Copyright (C) 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/}}
{{/* ---- Includes ---- */}}
{{Include "api_classnames.tmpl"}}
{{Include "cpp_common.tmpl" }}
{{/* ---- Overrides ---- */}}
{{Global "C++.EnumTypeOverride" "uint32_t" }}
{{Global "C++.Statement.Override" "Statement"}}
{{$filename := print (Global "API") "_state.h" }}
{{$ | Macro "State" | Format (Global "clang-format") | Write $filename}}
{{define "State"}}
{{AssertType $ "API"}}
{{Macro "C++.AOSP.Copyright"}}
{{$classname := Macro "ApiClassnames.State"}}
{{$guard := print "GAPII_" (Upper (Global "API")) "_STATE_H"}}
#ifndef {{$guard}}
#define {{$guard}}
#include "state_base.h"
#include "{{Global "API"}}_types.h"
#include <gapic/encoder.h>
#include <stdint.h>
namespace gapii
class {{$classname}} : public StateBase {
«public
inline {{$classname}}(ObserveFunc observe);
{{range $c := AllCommands $}}
inline void {{Macro "CmdName" $c}}({{Macro "Parameters" $c}});
{{end}}
{{range $g := $.Globals}}
{{Macro "C++.Type" $g}} {{$g.Name}};
{{end}}
#include "{{Global "API"}}_state_externs.inl"
};
inline {{$classname}}::{{$classname}}(ObserveFunc observe) : StateBase(observe) {}
{{range $c := AllCommands $}}
inline void {{$classname}}::{{Macro "CmdName" $c}}({{Macro "Parameters" $c}}) {
{{Macro "C++.Block" $c.Block}}
{{end}}
»} // namespace gapii
#endif // {{$guard}}
{{end}}
{{/*
-------------------------------------------------------------------------------
Emits the comma-separated list of type-name paired parameters for given
function, including the return value. All parameters are marked const.
-------------------------------------------------------------------------------
*/}}
{{define "Parameters"}}
{{AssertType $ "Function"}}
{{range $i, $p := $.CallParameters}}
{{if $i}}, {{end}}{{Macro "C++.ParameterType" $p}} const {{$p.Name}}§
{{end}}
{{if not (IsVoid $.Return.Type)}}
{{if len $.CallParameters}}, {{end}}{{Macro "C++.Type" $.Return.Type}} const result§
{{end}}
{{end}}
{{/*
-------------------------------------------------------------------------------
Emits the logic to execute the given statement without mutating outputs.
-------------------------------------------------------------------------------
*/}}
{{define "Statement"}}
{{ if IsAssign $}}{{Macro "C++.Statement.Default" $}}
{{else if IsMapAssign $}}{{Macro "C++.Statement.Default" $}}
{{else if IsReturn $}}return;
{{else }}{{Macro "C++.Statement.Default" $}}
{{end}}
{{end}}