Skip to content
This repository has been archived by the owner on Mar 26, 2020. It is now read-only.

Commit

Permalink
Test case for naming conflict fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Twyman committed Apr 22, 2016
1 parent 0466241 commit fe2fd05
Show file tree
Hide file tree
Showing 16 changed files with 492 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test-suite/djinni/test.djinni
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,12 @@ test_helpers = interface +c {
empty_record = record {

}

# Test for conflict of method name with an interface name.
# See the comments about scopeSymbols in CppMarshal.scala for more info.
Conflict = interface +c {
}
conflict_user = interface +c {
Conflict(): Conflict;
conflict_arg(cs: set<Conflict>): bool;
}
17 changes: 17 additions & 0 deletions test-suite/generated-src/cpp/Conflict.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni

#pragma once

namespace testsuite {

/**
* Test for conflict of method name with an interface name.
* See the comments about scopeSymbols in CppMarshal.scala for more info.
*/
class Conflict {
public:
virtual ~Conflict() {}
};

} // namespace testsuite
22 changes: 22 additions & 0 deletions test-suite/generated-src/cpp/conflict_user.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni

#pragma once

#include <memory>
#include <unordered_set>

namespace testsuite {

class Conflict;

class ConflictUser {
public:
virtual ~ConflictUser() {}

virtual std::shared_ptr<::testsuite::Conflict> Conflict() = 0;

virtual bool conflict_arg(const std::unordered_set<std::shared_ptr<::testsuite::Conflict>> & cs) = 0;
};

} // namespace testsuite
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni

package com.dropbox.djinni.test;

import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

/**
* Test for conflict of method name with an interface name.
* See the comments about scopeSymbols in CppMarshal.scala for more info.
*/
public abstract class Conflict {

private static final class CppProxy extends Conflict
{
private final long nativeRef;
private final AtomicBoolean destroyed = new AtomicBoolean(false);

private CppProxy(long nativeRef)
{
if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
this.nativeRef = nativeRef;
}

private native void nativeDestroy(long nativeRef);
public void destroy()
{
boolean destroyed = this.destroyed.getAndSet(true);
if (!destroyed) nativeDestroy(this.nativeRef);
}
protected void finalize() throws java.lang.Throwable
{
destroy();
super.finalize();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni

package com.dropbox.djinni.test;

import java.util.HashSet;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;

public abstract class ConflictUser {
@CheckForNull
public abstract Conflict Conflict();

public abstract boolean conflictArg(@Nonnull HashSet<Conflict> cs);

private static final class CppProxy extends ConflictUser
{
private final long nativeRef;
private final AtomicBoolean destroyed = new AtomicBoolean(false);

private CppProxy(long nativeRef)
{
if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
this.nativeRef = nativeRef;
}

private native void nativeDestroy(long nativeRef);
public void destroy()
{
boolean destroyed = this.destroyed.getAndSet(true);
if (!destroyed) nativeDestroy(this.nativeRef);
}
protected void finalize() throws java.lang.Throwable
{
destroy();
super.finalize();
}

@Override
public Conflict Conflict()
{
assert !this.destroyed.get() : "trying to use a destroyed object";
return native_Conflict(this.nativeRef);
}
private native Conflict native_Conflict(long _nativeRef);

@Override
public boolean conflictArg(HashSet<Conflict> cs)
{
assert !this.destroyed.get() : "trying to use a destroyed object";
return native_conflictArg(this.nativeRef, cs);
}
private native boolean native_conflictArg(long _nativeRef, HashSet<Conflict> cs);
}
}
21 changes: 21 additions & 0 deletions test-suite/generated-src/jni/NativeConflict.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni

#include "NativeConflict.hpp" // my header

namespace djinni_generated {

NativeConflict::NativeConflict() : ::djinni::JniInterface<::testsuite::Conflict, NativeConflict>("com/dropbox/djinni/test/Conflict$CppProxy") {}

NativeConflict::~NativeConflict() = default;


CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_Conflict_00024CppProxy_nativeDestroy(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef)
{
try {
DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef);
delete reinterpret_cast<::djinni::CppProxyHandle<::testsuite::Conflict>*>(nativeRef);
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, )
}

} // namespace djinni_generated
32 changes: 32 additions & 0 deletions test-suite/generated-src/jni/NativeConflict.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni

#pragma once

#include "Conflict.hpp"
#include "djinni_support.hpp"

namespace djinni_generated {

class NativeConflict final : ::djinni::JniInterface<::testsuite::Conflict, NativeConflict> {
public:
using CppType = std::shared_ptr<::testsuite::Conflict>;
using CppOptType = std::shared_ptr<::testsuite::Conflict>;
using JniType = jobject;

using Boxed = NativeConflict;

~NativeConflict();

static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeConflict>::get()._fromJava(jniEnv, j); }
static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<NativeConflict>::get()._toJava(jniEnv, c)}; }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); }

private:
NativeConflict();
friend ::djinni::JniClass<NativeConflict>;
friend ::djinni::JniInterface<::testsuite::Conflict, NativeConflict>;

};

} // namespace djinni_generated
43 changes: 43 additions & 0 deletions test-suite/generated-src/jni/NativeConflictUser.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni

#include "NativeConflictUser.hpp" // my header
#include "Marshal.hpp"
#include "NativeConflict.hpp"

namespace djinni_generated {

NativeConflictUser::NativeConflictUser() : ::djinni::JniInterface<::testsuite::ConflictUser, NativeConflictUser>("com/dropbox/djinni/test/ConflictUser$CppProxy") {}

NativeConflictUser::~NativeConflictUser() = default;


CJNIEXPORT void JNICALL Java_com_dropbox_djinni_test_ConflictUser_00024CppProxy_nativeDestroy(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef)
{
try {
DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef);
delete reinterpret_cast<::djinni::CppProxyHandle<::testsuite::ConflictUser>*>(nativeRef);
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, )
}

CJNIEXPORT jobject JNICALL Java_com_dropbox_djinni_test_ConflictUser_00024CppProxy_native_1Conflict(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef)
{
try {
DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef);
const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::ConflictUser>(nativeRef);
auto r = ref->Conflict();
return ::djinni::release(::djinni_generated::NativeConflict::fromCpp(jniEnv, r));
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */)
}

CJNIEXPORT jboolean JNICALL Java_com_dropbox_djinni_test_ConflictUser_00024CppProxy_native_1conflictArg(JNIEnv* jniEnv, jobject /*this*/, jlong nativeRef, jobject j_cs)
{
try {
DJINNI_FUNCTION_PROLOGUE1(jniEnv, nativeRef);
const auto& ref = ::djinni::objectFromHandleAddress<::testsuite::ConflictUser>(nativeRef);
auto r = ref->conflict_arg(::djinni::Set<::djinni_generated::NativeConflict>::toCpp(jniEnv, j_cs));
return ::djinni::release(::djinni::Bool::fromCpp(jniEnv, r));
} JNI_TRANSLATE_EXCEPTIONS_RETURN(jniEnv, 0 /* value doesn't matter */)
}

} // namespace djinni_generated
32 changes: 32 additions & 0 deletions test-suite/generated-src/jni/NativeConflictUser.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni

#pragma once

#include "conflict_user.hpp"
#include "djinni_support.hpp"

namespace djinni_generated {

class NativeConflictUser final : ::djinni::JniInterface<::testsuite::ConflictUser, NativeConflictUser> {
public:
using CppType = std::shared_ptr<::testsuite::ConflictUser>;
using CppOptType = std::shared_ptr<::testsuite::ConflictUser>;
using JniType = jobject;

using Boxed = NativeConflictUser;

~NativeConflictUser();

static CppType toCpp(JNIEnv* jniEnv, JniType j) { return ::djinni::JniClass<NativeConflictUser>::get()._fromJava(jniEnv, j); }
static ::djinni::LocalRef<JniType> fromCppOpt(JNIEnv* jniEnv, const CppOptType& c) { return {jniEnv, ::djinni::JniClass<NativeConflictUser>::get()._toJava(jniEnv, c)}; }
static ::djinni::LocalRef<JniType> fromCpp(JNIEnv* jniEnv, const CppType& c) { return fromCppOpt(jniEnv, c); }

private:
NativeConflictUser();
friend ::djinni::JniClass<NativeConflictUser>;
friend ::djinni::JniInterface<::testsuite::ConflictUser, NativeConflictUser>;

};

} // namespace djinni_generated
31 changes: 31 additions & 0 deletions test-suite/generated-src/objc/DBConflict+Private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni

#include "Conflict.hpp"
#include <memory>

static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file");

@class DBConflict;

namespace djinni_generated {

class Conflict
{
public:
using CppType = std::shared_ptr<::testsuite::Conflict>;
using CppOptType = std::shared_ptr<::testsuite::Conflict>;
using ObjcType = DBConflict*;

using Boxed = Conflict;

static CppType toCpp(ObjcType objc);
static ObjcType fromCppOpt(const CppOptType& cpp);
static ObjcType fromCpp(const CppType& cpp) { return fromCppOpt(cpp); }

private:
class ObjcProxy;
};

} // namespace djinni_generated

51 changes: 51 additions & 0 deletions test-suite/generated-src/objc/DBConflict+Private.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni

#import "DBConflict+Private.h"
#import "DBConflict.h"
#import "DJICppWrapperCache+Private.h"
#import "DJIError.h"
#include <exception>
#include <utility>

static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file");

@interface DBConflict ()

- (id)initWithCpp:(const std::shared_ptr<::testsuite::Conflict>&)cppRef;

@end

@implementation DBConflict {
::djinni::CppProxyCache::Handle<std::shared_ptr<::testsuite::Conflict>> _cppRefHandle;
}

- (id)initWithCpp:(const std::shared_ptr<::testsuite::Conflict>&)cppRef
{
if (self = [super init]) {
_cppRefHandle.assign(cppRef);
}
return self;
}

namespace djinni_generated {

auto Conflict::toCpp(ObjcType objc) -> CppType
{
if (!objc) {
return nullptr;
}
return objc->_cppRefHandle.get();
}

auto Conflict::fromCppOpt(const CppOptType& cpp) -> ObjcType
{
if (!cpp) {
return nil;
}
return ::djinni::get_cpp_proxy<DBConflict>(cpp);
}

} // namespace djinni_generated

@end
13 changes: 13 additions & 0 deletions test-suite/generated-src/objc/DBConflict.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from test.djinni

#import <Foundation/Foundation.h>


/**
* Test for conflict of method name with an interface name.
* See the comments about scopeSymbols in CppMarshal.scala for more info.
*/
@interface DBConflict : NSObject

@end
Loading

0 comments on commit fe2fd05

Please sign in to comment.