166a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer/* 266a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer * Copyright 2012 The Android Open Source Project 366a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer * 466a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer * Licensed under the Apache License, Version 2.0 (the "License"); 566a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer * you may not use this file except in compliance with the License. 666a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer * You may obtain a copy of the License at 766a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer * 866a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer * http://www.apache.org/licenses/LICENSE-2.0 966a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer * 1066a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer * Unless required by applicable law or agreed to in writing, software 1166a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer * distributed under the License is distributed on an "AS IS" BASIS, 1266a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1366a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer * See the License for the specific language governing permissions and 1466a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer * limitations under the License. 1566a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer */ 1666a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer 1766a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshoferimport java.io.PrintStream; 1866a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer 1966a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer/** 2066a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer * Emits a Java interface and Java & C implementation for a C function. 2166a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer * 2266a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer * <p> The Java interface will have Buffer and array variants for functions that 2366a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer * have a typed pointer argument. The array variant will convert a single "<type> *data" 2466a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer * argument to a pair of arguments "<type>[] data, int offset". 2566a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer */ 2666a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshoferpublic class EGLCodeEmitter extends JniCodeEmitter { 2766a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer 2866a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer PrintStream mJavaImplStream; 2966a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer PrintStream mCStream; 3066a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer 3166a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer PrintStream mJavaInterfaceStream; 3266a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer 3366a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer /** 3466a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer */ 3566a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer public EGLCodeEmitter(String classPathName, 3666a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer ParameterChecker checker, 3766a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer PrintStream javaImplStream, 3866a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer PrintStream cStream) { 3966a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer mClassPathName = classPathName; 4066a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer mChecker = checker; 4166a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer 4266a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer mJavaImplStream = javaImplStream; 4366a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer mCStream = cStream; 4466a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer mUseContextPointer = false; 4566a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer mUseStaticMethods = true; 4666a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer mUseSimpleMethodNames = true; 47c5ee93e5fe2de4390ee96fb3b14c41f6ca45f5a2Thomas Tafertshofer mUseHideCommentForAPI = false; 4866a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer } 4966a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer 5066a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer public void emitCode(CFunc cfunc, String original) { 5166a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer emitCode(cfunc, original, null, mJavaImplStream, 5266a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer mCStream); 5366a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer } 5466a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer 5566a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer public void emitNativeRegistration(String nativeRegistrationName) { 5666a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer emitNativeRegistration(nativeRegistrationName, mCStream); 5766a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer } 5866a42db8cbfba902f72f0ace5ac448ef4bfd3951Thomas Tafertshofer} 59