aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/d/hello_lib
diff options
context:
space:
mode:
Diffstat (limited to 'examples/d/hello_lib')
-rw-r--r--examples/d/hello_lib/BUILD42
-rw-r--r--examples/d/hello_lib/greeter.d51
-rw-r--r--examples/d/hello_lib/greeter_test.d22
-rw-r--r--examples/d/hello_lib/native-greeter.c49
-rw-r--r--examples/d/hello_lib/native-greeter.h28
-rw-r--r--examples/d/hello_lib/native_greeter.d43
6 files changed, 0 insertions, 235 deletions
diff --git a/examples/d/hello_lib/BUILD b/examples/d/hello_lib/BUILD
deleted file mode 100644
index 3b4f084737..0000000000
--- a/examples/d/hello_lib/BUILD
+++ /dev/null
@@ -1,42 +0,0 @@
-package(default_visibility = ["//visibility:public"])
-
-load(
- "//tools/build_defs/d:d.bzl",
- "d_docs",
- "d_library",
- "d_source_library",
- "d_test",
-)
-
-d_library(
- name = "greeter",
- srcs = ["greeter.d"],
-)
-
-d_test(
- name = "greeter_test",
- srcs = ["greeter_test.d"],
- deps = [":greeter"],
-)
-
-cc_library(
- name = "native_greeter_lib",
- srcs = ["native-greeter.c"],
- hdrs = ["native-greeter.h"],
-)
-
-d_source_library(
- name = "native_greeter",
- srcs = ["native_greeter.d"],
- deps = [":native_greeter_lib"],
-)
-
-d_docs(
- name = "greeter_docs",
- dep = ":greeter",
-)
-
-d_docs(
- name = "native_greeter_docs",
- dep = ":native_greeter",
-)
diff --git a/examples/d/hello_lib/greeter.d b/examples/d/hello_lib/greeter.d
deleted file mode 100644
index a0a3bf8db9..0000000000
--- a/examples/d/hello_lib/greeter.d
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright 2015 The Bazel Authors. All rights reserved.
-//
-// 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.
-
-module greeter;
-
-import std.stdio;
-import std.string;
-
-/// Displays a greeting.
-class Greeter {
- private string greeting;
-
- public:
- /// Creates a new greeter.
- ///
- /// Params:
- /// greeting = The greeting to use.
- this(in string greeting) {
- this.greeting = greeting.dup;
- }
-
- /// Returns the greeting as a string.
- ///
- /// Params:
- /// thing = The thing to greet
- ///
- /// Returns:
- /// A greeting as a string.
- string makeGreeting(in immutable string thing) {
- return format("%s %s!", this.greeting, thing);
- }
-
- /// Prints a greeting.
- ///
- /// Params:
- /// thing = The thing to greet.
- void greet(in immutable string thing) {
- writeln(makeGreeting(thing));
- }
-}
diff --git a/examples/d/hello_lib/greeter_test.d b/examples/d/hello_lib/greeter_test.d
deleted file mode 100644
index 4d927c5b01..0000000000
--- a/examples/d/hello_lib/greeter_test.d
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2015 The Bazel Authors. All rights reserved.
-//
-// 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.
-
-import examples.d.hello_lib.greeter;
-
-unittest {
- auto greeter = new Greeter("Hello");
- assert(greeter.makeGreeting("world") == "Hello world!");
-}
-
-void main() {}
diff --git a/examples/d/hello_lib/native-greeter.c b/examples/d/hello_lib/native-greeter.c
deleted file mode 100644
index 1ce489a941..0000000000
--- a/examples/d/hello_lib/native-greeter.c
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2015 The Bazel Authors. All rights reserved.
-//
-// 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.
-
-#include "examples/d/hello_lib/native-greeter.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-NativeGreeter* native_greeter_new(const char* greeting) {
- if (greeting == NULL) {
- return NULL;
- }
- NativeGreeter* greeter = NULL;
- greeter = (NativeGreeter*)malloc(sizeof(*greeter));
- if (greeter == NULL) {
- return NULL;
- }
- greeter->greeting = strdup(greeting);
- return greeter;
-}
-
-void native_greeter_greet(const NativeGreeter* greeter, const char* thing) {
- if (greeter == NULL || thing == NULL) {
- return;
- }
- printf("%s %s!\n", greeter->greeting, thing);
-}
-
-void native_greeter_free(NativeGreeter* greeter) {
- if (greeter == NULL) {
- return;
- }
- if (greeter->greeting != NULL) {
- free(greeter->greeting);
- }
- free(greeter);
-}
diff --git a/examples/d/hello_lib/native-greeter.h b/examples/d/hello_lib/native-greeter.h
deleted file mode 100644
index c998412c74..0000000000
--- a/examples/d/hello_lib/native-greeter.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2015 The Bazel Authors. All rights reserved.
-//
-// 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.
-
-#ifndef EXAMPLES_D_HELLO_LIB_NATIVE_GREETER_H_
-#define EXAMPLES_D_HELLO_LIB_NATIVE_GREETER_H_
-
-typedef struct NativeGreeter {
- char* greeting;
-} NativeGreeter;
-
-NativeGreeter* native_greeter_new(const char* greeting);
-
-void native_greeter_greet(const NativeGreeter* greeter, const char* thing);
-
-void native_greeter_free(NativeGreeter* greeter);
-
-#endif // EXAMPLES_D_HELLO_LIB_NATIVE_GREETER_H_
diff --git a/examples/d/hello_lib/native_greeter.d b/examples/d/hello_lib/native_greeter.d
deleted file mode 100644
index 605fe21ca7..0000000000
--- a/examples/d/hello_lib/native_greeter.d
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2015 The Bazel Authors. All rights reserved.
-//
-// 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.
-
-module native_greeter;
-
-extern (C):
-
-struct NativeGreeter {
- char* greeting;
-};
-
-/// Creates a new NativeGreeter.
-///
-/// Params:
-/// greeting = The greeting to use.
-///
-/// Returns:
-/// A pointer to a new NativeGreeting struct.
-NativeGreeter* native_greeter_new(const(char)* greeting);
-
-/// Prints a greeting to stdout.
-///
-/// Params:
-/// greeter = The pointer to the NativeGreeter object to use.
-/// thing = The thing to greet.
-void native_greeter_greet(const(NativeGreeter)* greeter, const(char)* thing);
-
-/// Frees the NativeGreeter.
-///
-/// Params:
-/// greeter = The pointer to the NativeGreeter object to use.
-void native_greeter_free(NativeGreeter* greeter);